submitHandler - Jquery Validate and Magento
For some reason I cannot get this to submit at all in magento. The form validates just fine. Its just it seems like once its validated it doesnt want to do anything.
$j('#send').click(function(){
var form = $j('#share_email_submit');
form.validate({
submitHandler: function(){
var data = $j(form).serialize();
alert(data);
$j.post('catdog.php', data);
}开发者_如何学Go
}).form();
});
Any ideas?
You can try to use the validate method of the validator magento object.
validator.validate()
It returns boolean false if magento validation failed otherwise true.
To activate the magento validation, you should have set somewhere in your code something as
var validate_form = new VarienForm('form_id',true);
It seems that in your code 'share_email_submit
' should be the above 'form_id
'
Then you can turn the code you posted into something like
$j('#send').click(function()
{
if (validate_form.validator.validate())
{
var form = $j('#share_email_submit');
var data = $j(form).serialize();
console.log(data);
$j.post('catdog.php', data);
}
else
{
console.log('Validation Failed');
}
return false;
});
精彩评论