//Check if it is not empty
function notEmpty(obj, msg )
{
str = obj.value;
str1 = "";
for (i = 0; i < str.length; i )
{
if (str .charAt(i) != " ")
{
str1 = str.substr(i, str.length);
break;
}
}
if (str1 = = "")
{
alert(msg);
obj.value = "";
obj.focus();
return false;
}
else
{
return true;
}
}
//Check if it is a number
function isNumber(obj, msg)
{
if(isNaN(obj.value ))
{
if (undefined == msg)
{
msg = "Please enter a number!";
}
alert(msg);
obj.select ();
return false;
}
else
{
return true;
}
}
//Check whether the passwords are the same
function isSamePwd( objPwd1, objPwd2, msg)
{
pwd1 = objPwd1.value;
pwd2 = objPwd2.value;
if (pwd1 != pwd2)
{
if (null == msg)
{
alert("Passwords are different!");
}
else
{
alert(msg);
}
objPwd2.value = "";
objPwd2.focus();
return false;
}
else
{
return true;
}
}
//check Email address
function isEmail(obj, msg)
{
ch = obj.value;
if((ch.indexOf("@") < 1) || (ch.indexOf( ".") < 1) || (ch.indexOf(".") == ch.length - 1))
{
if (null == msg)
{
alert ("Email is incorrect! ");
}
else
{
alert(msg);
}
obj.select();
return false;
}
else
{
return true;
}
}
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31