how to design two inputs in or/And logic for email form with validation
- by Raj Nimbalkar
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;
}