I am encountering an issue with the else if block in my Javascript code. It seems to be blocking all email IDs, even correct ones. Can someone assist with understanding what the match()
function returns?
I have tested the following scenarios:
- Empty field: working fine - Incorrect email ID: working fine - Correct email ID: not working
var pattern = new RegExp("/^(([^<>()[\]\\.,;:\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,}))$/");
if(!accountantEmail){
$("#infoTextMsg").hide();
$("#accountantEmailNoDataErr").show();
$("#accountantEmailInvalidFormat").hide();
$("#accountant_email").focus();
return false;
}
else if(!(pattern.test(accountantEmail))){
$("#accountantEmailInvalidFormat").show();
$("#infoTextMsg").hide();
$("#accountantEmailNoDataErr").hide();
$("#accountant_email").focus();
return false;
}