![]() |
|
|
| Subject:
Javascript coding
Category: Computers > Programming Asked by: xxbifferxx-ga List Price: $10.00 |
Posted:
08 Apr 2004 10:31 PDT
Expires: 08 May 2004 10:31 PDT Question ID: 327211 |
|
| Subject:
Re: Javascript coding
Answered By: googleexpert-ga on 08 Apr 2004 12:01 PDT Rated: ![]() |
Hi xxbifferxx,
Below is a function that checks if Both Textfields match AND if they
have 2 Numeric Characters:
<html>
<script language="JavaScript">
function Check()
{
var pass = document.frm.txt.value;
var pass2 = document.frm.txt2.value;
//Check if 2 Passwords Match contain 2 Numeric Characters
if( (pass == pass2)&&(pass.match(/[0-9].*?[0-9]/g)) )
{ alert("Matched!"); }
else
{ alert("No Match"); }
}
</script>
<table>
<form name="frm" onSubmit="Check();">
<tr>
<td>Enter Your Password: </td>
<td><input type="text" name="txt" size="30"></td>
</tr>
<tr>
<td>Enter Your Password Again:</td>
<td><input type="text" name="txt2" size="30"></td>
</tr>
<tr><td>
<input type="submit" name="submit" value="Password Check">
</td></tr>
</form>
</table>
</html>
Please let me know if you have anymore questions.
Thank you.
-googleexpert | |
| |
| |
xxbifferxx-ga
rated this answer:
and gave an additional tip of:
$2.00
Big thanks! This was a great help. |
|
| Subject:
Re: Javascript coding
From: lucos-ga on 08 Apr 2004 11:54 PDT |
Try...
function checknum(pass)
{
numbers = new Array(1,2,3,4,5,6,7,8,9,0);
flag=0;
for(i=0;pass.length;i++)
{
char = charAt(i);
for(i=0;i<10;i++)
{
if(char == numbers[(i)])
{
flag++;
}
}
}
if(flag > 2)
{
alert("This password has at least 2 numbers"); // OPTIONAL
}else{
alert("Sorry, invalid entry"); // PUT ERROR EVENT HERE
}
}
if(pass1 == pass2)
{
checknum(pass1);
checknum(pass2);
}else{
alert("Passwords are not the same");
}
Not tested, so probably better waiting for one of the researchers |
| Subject:
Re: Javascript coding
From: xxbifferxx-ga on 23 Apr 2004 10:50 PDT |
tried to make it work but it failed, probably me but thanks for your comment |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |