Magento registration form validated with VarienForm get response function

I am currently creating a registration form and validating it using the Magento VarienForm method. I just want to know how I can get an answer, has the user passed the test or not? If this fails, I will stop ajax. Here is my code:

var dataForm = new VarienForm('register-form', true);
jQuery('#register-form').submit(function(e){
    jQuery.post( "<?php echo $baseUrl; ?>quickcheckout/index/register", jQuery( "#register_form_mobile" ).serialize()).done(function( data ) {
    var successRegister = isNumber(data);
        if(successRegister)
        {
            location.reload();
        }
        else
        {
            console.log(data);
        }
    });
})
+3
source share
2 answers

http://magentotutorialbeginners.blogspot.in/2014/03/custom-from-validation-in-magento.html

 var theForm = new VarienForm('frm_feedback', true);  

Where frm_feedbackis your form id

   if (theForm.validator && theForm.validator.validate())   
   {
     // if validation successful pass then
   }
  else
  {
  //magento validation fire
   }
+10
source

Yes, I found the answer, hope it helps others:

var dataForm = new VarienForm('register-form', true);

if (!dataForm.validator.validate())
{
   //fail pass validation
}
else
{
  //success pass validation
}
0
source

All Articles