Form-validation

9
Jul

How to Add Confirmation email field in magento registration form using class validate-cemail?

The following method allows you to add confirmation email address field in your customer registration or newsletter page.

Create a javascript file called validation.js under “js/email/validation.js”

[php toolbar=”true” classname=”one_line”] Validation.addAllThese([

[‘validate-cemail’, ‘Please make sure your emails match.’, function(v) {
var conf = $(‘confirmation’) ? $(‘confirmation’) : $$(‘.validate-cemail’)[0];
var pass = false;
var confirm;
if ($(’email’)) {
pass = $(’email’);
}
confirm =conf.value;
if(!confirm && $(’email2′))
{
confirm = $(’email2′).value;
}
return (pass.value == confirm);
}],
]);
[/php]

Read more

9
Jul

Using Magento’s Built-In AJAX Submit With Validation

I’m creating a custom module and I want to be able to submit the form via Magento’s built-in AJAX. Also, I want to validate the user input to ensure I don’t get a database full of blanks!

Magento makes hooking into the existing functionality really quite easy. Let’s begin with the form.

Read more

9
Jul

Magento: Form validation

Most important thing besides assigning class names to form in magento is that little piece of JavaScript below the form. Remember to pass form id into the new VarienForm object.

Basically that’s it. Constructing the form this way, automatically makes your form reuse already existing validation code, the one that the rest of the shop is using.

Below is a full list of validate class and its error message that I found in prototype lib.

* validate-select

Please select an option.

Read more