Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > regular expressions

Reply
Thread Tools

regular expressions

 
 
Psybar Phreak
Guest
Posts: n/a
 
      09-27-2003
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
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      09-27-2003


Psybar Phreak wrote:

> 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
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      09-27-2003
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
 
Psybar Phreak
Guest
Posts: n/a
 
      09-27-2003
its not a school test.

im developing a php site and im in charge of validation

thanks

daina


"Evertjan." <> wrote in message
news:Xns9403AC041E935eejj99@194.109.133.29...
> 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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Regular Expressions in ASP.net Jay Douglas ASP .Net 3 11-03-2003 08:09 PM
Regular expressions mark Perl 4 10-28-2003 12:37 PM
perl regular expressions return last matched occurence? Dustin D. Perl 1 08-28-2003 01:51 AM
matching curly braces and regular expressions Dustin D. Perl 0 08-26-2003 11:18 PM
Add custom regular expressions to the validation list of available expressions Jay Douglas ASP .Net 0 08-15-2003 10:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57