jsUtils.isEmail()
Checks if the variable looks like an email address.
jsUtils.isEmail( str )
str - any javascript variable
Returns true if the variable looks like a valid email address or false otherwise.
The input variable is treated as a string in the format of an email address. This string is tested to look like a valid eamil address
it returns true if it does not look like an email, it returns false. The following regex is used:
/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/
Example
<!DOCTYPE html>
<html>
<head>
<script src="system/libs/jsUtils.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function() {
alert(jsUtils.isEmail('sometext'));
alert(jsUtils.isTime('sometext@1'));
alert(jsUtils.isTime('name@domain.com'));
}
</script>
<body>
</body>
</html>
See Also