i was wondering if how can you accept any extensions for the email address. and not by specific domain name extension.
For example
foo@surrey.ac.uk <-- needed to work and surrey is the extension
foo@survey.ac.uk <-- needed to work and survey is the extension
this is my code. this is working but the problem is that if you added a extension for the email ac.uk, its not accepting it. for example, if i registered an email foo@ac.uk, it works, but if you tried adding an extension for the email like foo@surrey.ac.uk or foo@survey.ac.uk, its not accepting it. i want it to have any extensions added to be working. THANK YOU GUYS!
//for custom email
jQuery.validator.addMethod('customemail', function(value, element) {
var s=value;
var split = s.split('@');
var regex = /^([a-zA-Z0-9_.+-])+$/;
var s2="ac.uk"; //The split array is the domain excluding the @
var optionalValue = this.optional(element); //This is how other methods in alternativeMethods.js Validator handle this.
//Debugging - This is useful to see visually what is happening
//alert(split[0]); // Shows the inputted username i.e chris or smokey
//alert(split[1]); // Shows the inputted domain
//alert(regex.test(split[0])); //Shows unfilled inputs problem or bad characters, true if good, false if bad
//alert(s2 == split[1]);** // Shows if the inputted domain matches variable s2, if it does we get a true
if (optionalValue) {
return optionalValue;
}
if(regex.test(split[0]) && (s2 == split[1])) // has to be == not equals
{
return true;
}
else
{
return false;
}
}, 'Please specify a Verified Email');
Some person reported this query as a duplicate from this post Email validation using jQuery
But my question is different since i needed a approved domain extension. not a general email validation