Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Code to know form validation
 
d8bhatta
Member
 
Total Posts:  44
Joined:  2009-06-11
 

Hello Guys,

After research of some hours, I able to know how we could know form is validated or not. And like to share it as well.

This is simple:

var signupForm = new Validation(\’form-validate\’);
var result = signupForm.validate();
if(result == true) {
$(\’#form-validate\’).submit();
return true;
}
else
return false;

I hope this helps somebody who need to perform some action after form validation.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
bgthw
Jr. Member
 
Total Posts:  4
Joined:  2010-05-16
 

Hello,

You can try this :

var signupForm = new VarienForm('signupForm'true);
if (
signupForm.validator && signupForm.validator.validate()) {
alert(
'yes');
else {
alert(
'oh no!');
}

Maybe it’s what you want.

BGTHW.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Yanith
Jr. Member
 
Total Posts:  22
Joined:  2011-09-21
 

I tried different methods including this one and the custom form kind of works.

when the person hasn’t filled anything, but clicks submit.  the form checks for the fields and displays the validation error. however, the form is sent as an empty email and the thank you page is loaded.

this only happens on the custom form all the other forms are working fine.

I’m suing this for a magento 1.6.1.0 template.

<script type="text/javascript\">
//< ![CDATA[
var rfq = new VarienForm(’eMail’);

//]]>
</script>

also using var rfq = new VarienForm(’eMail’, true);

but neither one works

this is my form tag:

<form id="eMail" name="eMail" method="post" action="<?php echo $this->getUrl('rfq/index/save'); ?>">

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top