Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

How to validate email address field 28.11.2013 05:01

There is a email address filed in my form. I need to validate the email address before calculation and sending email.

I wrote the code in Js event before calculation

var emailaddress = cb_getValue('email');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

if (!filter.test(emailaddress)) {
alert('Please provide a valid email address');
}

But after click the button in alert , it still doing calculation and send email to admin. What should I do?


Thank you very much

Re: How to validate email address field 28.11.2013 11:12

Hi,
you can add email validation to a text field just typing 'email', at the css class. It will use jquery validator to force the input to be a valid mail format before launching the calculator. You can check how does it work at the video:

Customizing input form

here

http://www.moonsoft.es/en/demo-calcbuilder-en

About
2:20 explains how to introduce the validation you need for your field.

Hope this helps,
Moonsoft Team
www.moonsoft.es

Re: How to validate email address field 28.11.2013 14:20

Thank you very much . It is a great help. It works !

There is another question. I would like to confirm the email in the next field , which means user type the email address must be the same as the previous one they type.

I check the jQuery documentation , there is a "equalTo()" method , so I type " equalTo(variable name)" in the CSS field, but it doesn't work.

Can you help me ? thank you

Jack

Re: How to validate email address field 28.11.2013 17:06

Hi,
that jquery method that uses parameters can't be set directly via css property. You can validate manually, for example if your fields are called 'field1' and 'field2', at the js tab execute before calculate execution:


if(cb_getValue('field1')!=cb_getValue('field2')){

alert("wrong!");
return false;
}


Hope this helps, regards
Moonsoft Team
www.moonsoft.es

Re: How to validate email address field 29.11.2013 03:47

Thank you for your help! Calc Builder is great :)

Re: How to validate email address field 03.12.2013 08:56

Hi mate

There is bug when using the code you provide

When I type the wrong email address in the " Confirm email" field and click the calculate button , it pops up the alert " please enter the same email address"

However , I click reset button and enter the right email address, then click calculator button again , it still pops up the alert

how to solve this problem ? thank you

Re: How to validate email address field 03.12.2013 09:48

Hi,
you can try to get the values in a different way, in order to ensure it recovers the actual value of each field:


if(CB("input[fldname=field1]").val()!=CB("input[fldname=field2]").val()){


.....



Hope this helps, regards
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect
FaLang translation system by Faboba

Our clients' feedback