I want to check if in a email textbox form field, email has correct syntax, but for Mobile Browsers, in desktop I used below, this will work foe Mobile Devices too?
or better check this on server side(PHP)...(check second snippet)?
function checkFormtemplate() // javascript used success desktop browsers
{
if (document.getElementById("email-login").value == "") {
alert("Error: Username(email) cannot be blank!");
document.getElementById("email-login").focus();
return false;
}
var retemplate = /^[a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])+@[a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])+\.[a-zA-Z\.]{2,4}/
var str=document.getElementById("email-login").value;
if (!retemplate.test(str)) { //
alert("Error: Username must contain only letters, numbers, dash, dot, underscores(first part) and the 'at' sign!");
document.getElementById("email-login").focus();
return false;
}
..........................................
..........................................
// php used success
..........................................
if (!eregi("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$",$_POST['email'])) { //
$message.="Error: Username must contain only letters, numbers, dash, dot, underscores(first part) and the 'at' sign!\n"; // @
$booleanValue=false;
}
..........................................