how to design two inputs in or/And logic for email form with validation
Posted
by
Raj Nimbalkar
on Stack Overflow
See other posts from Stack Overflow
or by Raj Nimbalkar
Published on 2012-07-01T21:12:27Z
Indexed on
2012/07/01
21:15 UTC
Read the original article
Hit count: 260
my purpose is user enter only email or mobile number.i have the partial success in that.code notify user in OR logic but....
IF user entered the incorrect mobile & email @same time then user must be notified for dat.
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var emailaddressVal = $("#UserEmail").val();
////email & mobile input cheak
if(emailaddressVal == '' && $("#mobile").val() == '') {
$("#UserEmail").after('<p><span class="error">Please enter your email address.</span></p>')
$("#mobile").after('<p><span class="error">Please enter your Mobile number.</span></p>')
hasError = true;
}
//////validating currect email
else if(!emailReg.test(emailaddressVal)) {
$("#UserEmail").after('<p><span class="error">Enter a valid email address.</span></p>')
hasError = true;
}
//////Mobile number
else if( $("#mobile").val()) {
$("#mobile").after('<p><span class="error">Enter currect Mobile number.</span></p>')
hasError = true;
}
© Stack Overflow or respective owner