We’re rewarding the question askers & reputations are being recalculated! Read more.
25

Excellent question! You don't need jQuery for this. You can do this with the built-in Magento form validator. First the javascript to set up the form for validation must be placed in your form template: <script type="text/javascript"> var myForm= new VarienForm('[your form id]', true); </script> Now prepare your form fields by adding the ...


15

There are two ways to include javascript from the template in Magento 2: the <script type="text/x-magento-init"> and the data-mage-init attribute. Either way can be used to pass data to the script within the json definition. For example, using the x-magento-init script tag, in the template you have: <script type="text/x-magento-init"> { ...


12

In your local.xml: <reference name="head"> <action method="addJs" name="jquery" as="jquery"> <script>jquery-1.10.2.js</script> </action> <action method="addJs"> <script>noconflict.js</script> </action> </reference> and noconflict.js would simply be $j = jQuery....


10

Aside from jQuery being lightly adopted during the development of Magento we must consider another aspect: Magento was developed around 2007 at a time when TC39 was proposing EcmaScript 5 and it was not fully implemented or developed. Prototype.JS aimed to solve this issue by bringing ECMA5 features to legacy browsers which lacked support at the time. ...


7

The Form-Validator is defined here: /app/design/frontend/base/default/template/sendfriend/send.phtml:135 var productSendtofriendForm = new VarienForm('product_sendtofriend_form'); and the VarienForm has a validator and this validator has a reset method: /js/prototype/validation.js:155 reset : function() { Form.getElements(this.form).each(Validation....


6

It would be helpful to see the code in and around line 38 in wishlist.js, as that's where the "real" error is triggered. (anonymous function) wishlist.js:38 The code you've linked is Prototype JS framework code, and the problem is something dodgey was passed into the framework code. Additionally, most Prototype JS/jQuery conflicts are cause by not being ...


5

This error occurs because of the conflict between prototype and jQuery libraries. To solve this, add jQuery.noConflict(); at the end of jQuery library. This will solve the conflict.


5

Here is how you can either override an existing validation method or create your own. There is only one js snippet below bc its the exact same procedure for either one. In my example, I override an existing Magento validation type. First, add your custom js file to whatever page(s) you need: <reference name="head"> <action method="addItem">&...


4

I tried some thing and it is working fine for me, i am sharing code hope this might be useful for someone else or one can suggest me the better approach. In mage\app\design\frontend\your-design-package\default\template\catalog\product\list.phtml Replace the following code <?php if($_product->isSaleable()): ?> <button type="button" title="...


4

Create a new .js file for eg. no-conflict.js and add the following content on it: var $j = jQuery.noConflict(); And include your no-conflict.js just after your <action method="addJs"><script>jquery-1.8.2.min.js</script></action> like this: <action method="addJs"><script>no-conflict.js</script></action> ...


4

Here's a way that should work and no need to modify a core JS file. Just drop it into a custom JS file and ensure it's included after validation.js. Validation.add('validate-password', 'Please enter 8 or more characters. Leading or trailing spaces will be ignored.', function(v) { var pass=v.strip(); /*strip leading and trailing spaces*/ return !(...


4

You need form param serialize, and send form fields as it as param to ajax request new Ajax.Request(url,{ method:'POST', parameters:params, requestHeaders: {Accept: 'application/json'}, onSuccess:function(transport){ var response=transport.responseText.evalJSON(true); }.bind(this) }); If you work with varien form stucture ...


4

http://prototypejs.org/learn/introduction-to-ajax new Ajax.Request('/some_url', { method: 'post', parameters: {company: 'example', limit: 12} }); Use Google more. There are many examples.


4

Add a class called "validate-digits" to your input type text line in the form.bascially it will look like <input type="text" class="(your_other_classes) validate-digits" /> for more validation classes you can refer Form Validation in Magento Note : 'validate-digits' => 'Please use numbers only in this field. Please avoid spaces or other characters ...


4

instead of var checkboxes = document.getElementsByName(chkboxName); try prototype var checkboxes =$$('#billship input[type="checkbox"][name="invoice_ids"]');


3

If you know how to code with Prototype you might want to continue using it since it won't make you struggle with compatibility between JS libs. If not, the struggle now is not that complex since jQuery can be easily included in a compatible way using noConflict() and work along with Prototype. As for the advantages/performance, jQuery is pretty new and at ...


3

There are a lot of classes for data validation: 'validate-no-html-tags' => 'HTML tags are not allowed' 'validate-select' => 'Please select an option.' 'required-entry' => 'This is a required field.' 'validate-number' => 'Please enter a valid number in this field.' 'validate-number-range' ...


3

I had exactly the same issue. In order to fix this issue you just have to add the js/script.js file in the head block in your layout and before adding the js/wishlist.js file, it would be something like this: <?xml version="1.0" encoding="UTF-8"?> <layout> <default> <reference name="head"> [...] &...


3

We had the same issue and discovered the js/scripts.js file wasn't even loading in our theme. Updating our page.xml to include the call resolved the issue: <action method="addItem"><type>skin_js</type><name>js/scripts.js</name></action>


3

I used the below Code & its Done Element.hide('loading_mask_loader');


3

found the answer, to unregister the varienloaderhandler new Ajax.Request('<?php echo $this->getUrl('adminhtml/notification/check') ?>', { //parameters: {isAjax: 'true', form_key: FORM_KEY},# method: 'post', onCreate: function(request) { Ajax.Responders.unregister(varienLoaderHandler.handler); }, ...


3

I know it's a bit backwards, but you can access the Validation object inside your validation method and then modify it dynamically while you run your test. What you can do is for example, add a new method to the Validation object: Validation.updateError = function(validationName, e, error){ var validation = Validation.get(validationName), advice ...


3

I modified the popup code, this worked for my needs. function addNewPop(id,title,w,h){ win = new Window({ title: title, className:"magento", destroyOnClose: true, recenterAuto:false, width:w, height:h, id: title, minimizable: false, maximizable: false, showEffectOptions: { duration: 0.4 }, ...


2

This was confirmed as a corebug, Magento gave the patch and as stated they fixed escaping the js. You can just contact Magento for the patch.


2

This worked for me for the telephone attribute. I addapted the script for firstname, but please check it again, in case I missed something. $firstname = Mage::getSingleton('eav/config')->getAttribute('customer', 'firstname'); $rules = $firstname->getValidateRules(); $validationClasses = array(); if (isset($rules['min_text_length'])){ $...


2

If you want to bail out from already opened catalog you want to use template/catalog/product/list.phtml and template/catalog/product/new.phtml If you want to do it correctly, i.e. BEFORE opening the folder, you might want to look into template/catalog/navigation.phtml (those templates render left and top navigation menu).


2

The issues in IE 9 were not due to the release of Prototype 1.7. They were due to incompatibles IE 9 had with the existing versions of Prototype used by Magento at the time. The quick and easy solution was (as you noted) putting IE 9 into IE 8 mode to ensure compatibility. It was way cheaper than upgrading and/or trying to solve the issues with the core JS ...


2

You will need to include the wysiwyg javascript files. I think the lines of code you need are. <script type="text/javascript" src="<?php echo $this->getJsUrl() ?>tiny_mce/tiny_mce.js"></script> And <action method="addItem"><type>js</type><name>mage/adminhtml/wysiwyg/tiny_mce/setup.js</name><params/>...


2

I would try returning the json response like this: $status = "PASS"; $jsonStatus = 200; $info = array( "status" => $status); $this->getResponse()->setBody(json_encode($info))->setHttpResponseCode($jsonStatus)->setHeader('Content-type', 'application/json', true); return $this; If you set the $status to 504 you will return an error.


2

It means validOptions[i] is not a string. Use console.log(validOptions[i]); to find out what it is. It might be undefined. Optionally you can do the following to ensure it's always a string validOptions[i].toString().toLowerCase()....


Only top voted, non community-wiki answers of a minimum length are eligible