HighDots Forums  

regular expressions

Javascript JavaScript language (comp.lang.javascript)


Discuss regular expressions in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Psybar Phreak
 
Posts: n/a

Default regular expressions - 09-27-2003 , 08:52 AM






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

thanks

PP


--------

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




Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: regular expressions - 09-27-2003 , 09:20 AM








Psybar Phreak wrote:

Quote:
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))

--

Martin Honnen
http://JavaScript.FAQTs.com/



Reply With Quote
  #3  
Old   
Evertjan.
 
Posts: n/a

Default Re: regular expressions - 09-27-2003 , 09:54 AM



Psybar Phreak wrote on 27 sep 2003 in comp.lang.javascript:
Quote:
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>")


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


Reply With Quote
  #4  
Old   
Psybar Phreak
 
Posts: n/a

Default Re: regular expressions - 09-27-2003 , 06:38 PM



its not a school test.

im developing a php site and im in charge of validation

thanks

daina


"Evertjan." <exjxw.hannivoort (AT) interxnl (DOT) net> wrote

Quote:
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>")


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.