regular expressions

P

Psybar Phreak

hi all, was hoping someone could provide a regex for the following
situation - im pulling my hair out

thanks

PP
 
M

Martin Honnen

Psybar said:
hi all, was hoping someone could provide a regex for the following
situation - im pulling my hair out

Q) password needs to contain at least one number and have a minimum length
of 6

I guess what you want is at least one digit and a minimum length
if (document.formName.passwordName.value.length >= 6
&& /\d/.test(document.formName.passwordName.value))
 
E

Evertjan.

Psybar Phreak wrote on 27 sep 2003 in comp.lang.javascript:
hi all, was hoping someone could provide a regex for the following
situation - im pulling my hair out

Q) password needs to contain at least one number and have a minimum
length of 6

[If this is a school test, you take the credit, but not earn it]

function testing(x){
return /\d/.test(x) && /\S{6,}/.test(x)
}

document.write(testing("asdasdd4")+"<br>")
document.write(testing("asdasdZZ")+"<br>")
document.write(testing("dd4")+"<br>")
 
P

Psybar Phreak

its not a school test.

im developing a php site and im in charge of validation

thanks

daina


Evertjan. said:
Psybar Phreak wrote on 27 sep 2003 in comp.lang.javascript:
hi all, was hoping someone could provide a regex for the following
situation - im pulling my hair out

Q) password needs to contain at least one number and have a minimum
length of 6

[If this is a school test, you take the credit, but not earn it]

function testing(x){
return /\d/.test(x) && /\S{6,}/.test(x)
}

document.write(testing("asdasdd4")+"<br>")
document.write(testing("asdasdZZ")+"<br>")
document.write(testing("dd4")+"<br>")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top