|
the user password must consists of a number. My code is failing
on this line. Some guideance will be appreciated from u experts
if (var_digits.indexOf(document.user.password.value.charAt(i))== 0) (failing line)
CODE BEGIN HERE
if (document.user.password.value.length >= 7)
{
password_length=document.user.password.value.length ;
var_digits= "0123456789";
password_number = 0;
for (i=0; i<=password_length; i++)
{
if (var_digits.indexOf(document.user.password.value.charAt(i))== 0)
{
password_number = 1;
break;
}
}
if (password_number == 0)
{
missinginfo += "\n Password must have atleast one number";
}
}
|
|
|
Hi,
I also have to check that some fieldvalue is numeric or not!
This is the code I use and it works.
Good luck!!
var passw = document.user.password.value;
var ValidChars = "0123456789.";
var IsNumber=true;
var Char=``;
for (i = 0; passw.length > i && IsNumber == true; i++)
{
Char = passw.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
if (IsNumber)
{}
else
{
alert(`There must be a number in the password!`);
}
|
|
|
thanks for suggestion it helped alot
|
|
|
|
|
|
|
|