Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
52
rated 0 times [  56] [ 4]  / answers: 1 / hits: 19261  / 10 Years ago, fri, june 13, 2014, 12:00:00

Magento has awesome Javascript validation library, which can be initialized var myForm= new VarienForm('[your form id]', true);. However this validation function is triggered when one click on submit button.



Is not there way to validate particular field as you type. For example if I type postal code 2 digit and go to second field, it should instantly validate postal code and show error. As postal code require at least 5 digits.



thanks


More From » magento

 Answers
20

Yes, Magento provide awesome validation library. You can call validation for each field with `validate' method.



For example to validate zip code, you can observe blur event and call validate method.



$('billing:postcode').observe('change', function(e){
Validation.validate($('billing:postcode'))
})


Notice Validation.validate($('billing:postcode')), this will call validation for postcode field.


[#70589] Wednesday, June 11, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylie

Total Points: 121
Total Questions: 84
Total Answers: 91

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
;