validation does not work in popup form values in magento - magento

I am using Ajax for sending data on controller. Here I use TinyMCE editer in my popup form and I need to validate it. But here validation does not work properly in Magento.

Yes you should clarify more on this.
By the way wherever you have put your form in popup give it an ID like and in your form if you have text boxes then put class 'required-entry' in all required textboxes and you should have one submit button.
Then finally put this script after form :
<script type="text/javascript">
//<![CDATA[
var popupForm = new VarienForm('popupform', true);
//]]>
</script>
See how it goes.

Related

Edit hyperlink validation

Is there any possibility to add another protocol to the hyperlink-type in sharepoint?
I want to add a notes (notes://***) to the top level navigation-bar.
Is there something I can extend or where I can edit the validation
By default, SharePoint navigation Hyperlinks must begin with http://,https://,mailto:,ftp://,file://,/,# or \.
If you want to use the "notes://***", as a workaround, you can add the link using jQuery code.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$(".ms-core-listMenu-horizontalBox>ul>li>ul").append("<li class='static'><a href='notes://xxx'>MyNote</a></li>");
});
</script>
Probably it is not possible to turn off easily the OOB link validation without any customization. Depends on the output You need maybe You could use a note column and in edit HTML content of the filed just put the link tag manually like:
someLink
. After save SharePoint will render it as link on list webpart.

TinyMCE not working on Ajax calls

I have a select.php page where the user selects a value from the dropdown. On selection the ajax code runs and information from ajax.php gets populated on the "display" div of the select.php page. Some of the information coming from ajax.php is in the form of textarea. But it gets displayed just as textarea, and not as tinymce editor. Even though I have called it in the head section of my page.
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script>
tinymce.init({
selector: 'textarea'
});
</script>
My problem is very similar to this: How do I initialize TinyMCE on a ajax loaded textarea in 4.x?
But I am not understanding the solution. Please help.
you can get data after that set data on tiny
success: function (data) {tinyMCE.get(data).getContent().replace('\'', "\’");},
Your call to tinymce.init() only acts on items in the DOM at the time the init() function is run. If you are adding additional <textarea> fields to the page later you need to run tinymce.init() after you add those elements to the DOM.
You can include a call to tinymce.init() in the same block of code that injects the <textarea> into the page directly after you inject the <textarea>.

Adding javascript function to a grocerycrud add or edit form

Is it possible to add a javascript function to the add/edit forms of grocery_CRUD?
E.g. As a user is typing in a particular field when adding or editing a record I want to execute a javascript on the keydown event.
If so, how?
It is possible.
For example, you call the view like this:
$this->load->view('grocery_crud_view', $output);
In the beginning of the view (grocery_crud_view.php), you can add any javascript
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascrpt">
$("#field-code").keyup(function(){
alert("there is a keyup");
});
</script>
<?php
// The rest of default php code
?>
Most of the id of the grocery-CRUD view (if you use flexigrid theme) would be something like this : "field-your_field_name"
You can inspect with firebug or google-chrome developer tools to ensure it.

How to call alert() javascript function in CodeIgniter

How could I display an alert from the controller class in CodeIgniter?
Typically you want to place any display content (such as HTML or Javascript) in a view, not in a controller. From the controller you load the view, and the view contains this code somewhere in it:
<script type="text/javascript">
alert('your alert');
</script>
See the CodeIgniter user_guide for more basics on how to structure your application:
http://www.codeigniter.com/user_guide
Anything you "print" using PHP's print, displays to the screen.
print "<script type=\"text/javascript\">alert('Some text');</script>";

Why does form validation not work in MVC3 partial views?

Anybody? There is another question regarding this but the only answers were to code up some javascript validation, which also refuses to work on my partial view ("$ is not defined").
Anyway, I don't want to use javascript I just want simple validation for required fields that cannot be left blank, number fields that require ints, etc.
Can anyone shed some light on validation and partial views?
I suspect that you are loading those partial views using AJAX. If this is the case you will need to manually invoke the $.validator.unobtrusive.parse method once you inject the new contents of the partial into the DOM as explained in this article.
Brad Wilson also discussed this in his blog post:
The unobtrusive client validation script automatically parses the
initial set of HTML for validation rules when the page has finished
loading. If your page dynamically adds new HTML content (perhaps
throught Ajax or through client-side application code), you may wish
to parse that new HTML for client validation on the new HTML elements.
To parse new HTML, you can call the
jQuery.validator.unobtrusive.parse() method, passing it a selector for
the HTML that you would like to be parsed. You can also call the
jQuery.validator.unobtrusive.parseElement() function to parse a single
HTML element.
As far as the $ is not defined error you should make sure that you have included the proper scripts:
<script src="#Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
Also make sure you are not referencing any of the Microsoft*.js scripts. They are obsolete and should no longer be used in ASP.NET MVC 3.
Of course that's only a supposition, you haven't shown any code so we cannot know what you are doing.
I'm having the same problem and i found that it's not possible to call $.validator.unobtrusive.parse() on the same form twice.
When loading the form initially from the server the form is parsed automatically by the unobtrusive library. When you add an input element dynamically to the form and call $.validator.unobtrusive.parse() again, it won't work. The same goes for parseElement().
So before you call $.validator.unobtrusive.parse, remove the original validator and unobtrusive validation from the form like so:
success: function (html) {
$("#div-id").append(html);
var form = $("#div-id").closest("form");
form.removeData('validator');
form.removeData('unobtrusiveValidation');
$.validator.unobtrusive.parse($("#editorRows"));
}

Resources