Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password check 2

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
Hi All!

How can i check whether the entered password has atleast one alpha character(/([A-Z][a-z])/) and atleast one number(/\d/)....

I tried some thing like this ...

var s=document.f1.pwd.value;

if(s=/([a-z][A-Z][0-9])+/)
{
alert("please check your password");
}

its not working ...any advice will be greatly appreciated.

Thank you.




 
I think you need sommat like this:


Code:
var s=document.f1.pwd.value;
var filter  = /([a-z][A-Z][0-9])/;

if(filter.test(s))
  alert("please check your password");

good luck

simon
 
I think you need sommat like this:


Code:
var s=document.f1.pwd.value;
var filter  = /([a-z][A-Z][0-9])/;

if(!filter.test(s))
  alert("please check your password");

good luck

simon
 
Thanks Simon...But its not working ...let say i have password "test2004" or "Test2004" its valid password ...

if password say ..."tested" or "20042004" its not a valid password it should have atleast one numeric character or one alpha (Aa-Zz) character.

Is any other option avaliable ...

Thank you.
 
i'm a newbie for RegExp. i don't know how to validate the password in a RegExp statement, so split into 2 as follows.
Code:
var s=document.f1.pwd.value;
var filter1=/[a-zA-Z]{1,}/;
var filter2=/[0-9]{1,}/;
if ((!filter1.test(s))||(!filter2.test(s))) {
  alert("please check your password");
}
hope this helps!
 
i dont think u should use one regexp for this situation.
try this:
Code:
strng="1a"
if(!(strng.match(/[a-z]/i) && strng.match(/\d/i)))
{
	alert("wrong")
}

this ought to work...

Known is handfull, Unknown is worldfull
 
cool :) Thank you all.

It works.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top