codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  trying to validate a users input (password) using html form and javascript  Archive Import (lb) at 13:37 on Wednesday, May 14, 2003
 


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";
}
}


  Re: trying to validate a users input (password) using html form and javascript  Archive Import (Ellen) at 04:25 on Thursday, May 15, 2003
 

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!`);
}


  Re: trying to validate a users input (password) using html form and javascript  Archive Import (lb) at 12:59 on Thursday, May 15, 2003
 

thanks for suggestion it helped alot








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Ajax example: online chat
•  Re: Nested Javascripts
•  ISP says linefeeds are causing problems
•  Linker Error Unresolved External Borland Builder 2006
•  Have multiple ASP.NET web projects share pages and controls
•  Re: How can I read ASCII data file in C++
•  Trouble writing programs
•  Validation Problem
•  Date formating from user input


Recent Articles
What is a pointer in C?
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net


© Copyright codetoad.com 2001-2006