Using a regular expression to validate a email address wrapped

04ZNlatosha

New Member
How can a full email address be validated in Javascript?\[code\]var VALIDAR = { email: function (input){ input = input.replace (";",","); var listcorreo = input.split (","); for (var i = 0; i < listcorreo.length; i++) { if (listcorreo .search (/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/ig)) { return false; } } return true; }}alert (VALIDAR.email ("[email protected]")); // TRUEalert (VALIDAR.email ("[email protected],[email protected]")); // TRUEalert (VALIDAR.email ("John Smith <[email protected]>")); // FALSE\[/code\]But I need to validate that email \[code\]John Smith <[email protected]>\[/code\] returns TRUE.Try Here
 
Back
Top