Monday, 15 July 2013

javascript - Validating more that one email field -



javascript - Validating more that one email field -

im using joren rapini's validation code online form. joren's website

it allows check see if email address has been correctly entered, have 2 email addresses want validate in form.

any thought how this?

i've tried adding in email = $("#youremail"); 1 that's in code email = $("#receiveremail"); works one.

$(document).ready(function(){ // place id's of required fields here. required = ["youremail", "name", "receiveremail", "message"]; // if using id other #email or #error replace here email = $("#receiveremail"); errornotice = $("#error"); // text show within field when wrong emptyerror = "please fill out field"; emailerror = "not vaild email"; });

you need run validation code other field

in document.ready

otheremail = $("#otheremail");

in form submit

if (!/^([a-za-z0-9_\.\-])+\@(([a-za-z0-9\-])+\.)+([a-za-z0-9]{2,4})+$/.test(otheremail .val())) { otheremail .addclass("needsfilled"); otheremail .val(emailerror); }

no offense joren rapini code hacky , shouldn't used other smallest purpose.

javascript jquery

No comments:

Post a Comment