Skip to main content
added 10 characters in body
Source Link

Magento 1.x does not come with jQuery validator natively but with Prototype that permits to validate form the way you describe. To check the different validators avialable you can have look at js/prototype/validation.js on line 414. You can add your own by doing something like that in foo.js (I did not test the regex but I think it is not the point) :

Validation.add('validate-foo', 'The entry must be foo', function(v) {
    return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9._%-]*foo[a-zA-Z0-9._%-]*)$/i.test(v)
})

Then you need to add the js in your layout :

<default>
    <reference name="head">
        <action method="addJs"><script>foo.js</script></action>
    </reference>
</default>

Magento 1.x does not come with jQuery natively but with Prototype that permits to validate form the way you describe. To check the different validators avialable you can have look at js/prototype/validation.js on line 414. You can add your own by doing something like that in foo.js (I did not test the regex but I think it is not the point) :

Validation.add('validate-foo', 'The entry must be foo', function(v) {
    return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9._%-]*foo[a-zA-Z0-9._%-]*)$/i.test(v)
})

Then you need to add the js in your layout :

<default>
    <reference name="head">
        <action method="addJs"><script>foo.js</script></action>
    </reference>
</default>

Magento 1.x does not come with jQuery validator natively but with Prototype that permits to validate form the way you describe. To check the different validators avialable you can have look at js/prototype/validation.js on line 414. You can add your own by doing something like that in foo.js (I did not test the regex but I think it is not the point) :

Validation.add('validate-foo', 'The entry must be foo', function(v) {
    return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9._%-]*foo[a-zA-Z0-9._%-]*)$/i.test(v)
})

Then you need to add the js in your layout :

<default>
    <reference name="head">
        <action method="addJs"><script>foo.js</script></action>
    </reference>
</default>
Source Link

Magento 1.x does not come with jQuery natively but with Prototype that permits to validate form the way you describe. To check the different validators avialable you can have look at js/prototype/validation.js on line 414. You can add your own by doing something like that in foo.js (I did not test the regex but I think it is not the point) :

Validation.add('validate-foo', 'The entry must be foo', function(v) {
    return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9._%-]*foo[a-zA-Z0-9._%-]*)$/i.test(v)
})

Then you need to add the js in your layout :

<default>
    <reference name="head">
        <action method="addJs"><script>foo.js</script></action>
    </reference>
</default>