iFormBuilder JavaScript Tips & Tricks
How do I validate an e-mail address?
To validate that an email address is well-formed, please follow the instructions below.
STEP 1. From inside the Form Builder, click the Page Level Javascript icon.
STEP 2. Place the following function in the JavaScript field.
function validateEmail(emailVal) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(emailVal);
}
STEP 3. Create an email element with a data column name of email.
STEP 4. In the Dynamic Value field of the email element, put email="". This sets the element to an empty string.
STEP 5. In the Client Validation field of the email element put validateEmail(email) || email=="".
STEP 6. In the Validation Message field of the email element, enter your validation message. Example: "Please enter a valid e-mail address to submit"
STEP 7. Test the Client Validation on the form.
Comments
1 comment
Now that is something very nice step by step explanation. I have been searching for it. Thank you very much for the post. I will definitely put the knowledge into use and obviusly, this link of your will be recommended.
Thanks and Regards
Ravi
Please sign in to leave a comment.