Hi all,
hope someone can help me,
I am looking to do a password validation check using client side
validation. Minimum requirement is that it must contain at least one
number and one letter. (Ideally it would be of 6-20 characters in
length but first things first).
I have came up with the following regEx
^(\w*(?=\w+\d+)(?=\w*[a-zA-Z])\w*)$
This works fine in IE but when testing it using NS6 it won't validate
'1password', but will validate 'password1'. It seems the first forward
search is consuming the first character in NS, would this be correct,
and if so can anybody suggest either a way arround this or a different
regular expression,
Thanks in advance,
SJM. 9 2168
Stirling wrote on 15 mei 2004 in comp.lang.javascript : I am looking to do a password validation check using client side validation. Minimum requirement is that it must contain at least one number and one letter. (Ideally it would be of 6-20 characters in length but first things first).
I have came up with the following regEx
^(\w*(?=\w+\d+)(?=\w*[a-zA-Z])\w*)$
This works fine in IE but when testing it using NS6 it won't validate '1password', but will validate 'password1'. It seems the first forward search is consuming the first character in NS, would this be correct, and if so can anybody suggest either a way arround this or a different regular expression,
function pwTest(w){
t1 = /^[a-z\d]{6,20}$/i // only and length
t2 = /[a-z]/i // at least 1 letter
t3 = /\d/ // at least 1 number
return t1.test(w) && t2.test(w) && t3.test(w)
}
alert(pwTest("1qweqweasd"))
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
"Stirling" wrote I am looking to do a password validation check using client side validation. Minimum requirement is that it must contain at least one number and one letter. (Ideally it would be of 6-20 characters in length but first things first). <snip>
Lookahead regexes are not very widely supported. Look at this:
var pword='djuhy9dgyg';
alert( /[a-z]/i.test( pword ) && /\d/.test( pword ) && /.{6,20}/.test(
pword ) )
// alerts true or false
Three little regexes may not be the most efficient way, but would be fast
enough for me.
Ivo
Stirling <fa*******@NOSPAM.com> writes: I am looking to do a password validation check using client side validation. Minimum requirement is that it must contain at least one number and one letter.
I have came up with the following regEx
^(\w*(?=\w+\d+)(?=\w*[a-zA-Z])\w*)$
The matches a sequence of word-characters (a requirement you didn't
mention?) that contains at least one digit(!) after a word character,
and at least one letter. The reason you don't match "1password" is
the first + in (?=\w+\d+).
A simpler version could be:
/^(?=\w*\d)(?=\w*[A-Z])\w{6,20}$/i
Still, you are relying on lookahead, which only exists in newer
browsers, and which IIRC is broken in IE. In many cases, making
more than one test is much simpler than trying to encode everything
into one RegExp.
function testPasswd(pw) {
return /[a-z]/i.test(pw) && /\d/.test(pw) && /^\w{6,20}*$/.test(pw);
}
This works fine in IE but when testing it using NS6 it won't validate '1password', but will validate 'password1'.
That supports my recollection that lookahead in IE is broken, because
it should not match "1password".
It seems the first forward search is consuming the first character in NS, would this be correct,
Yes, because you asked it to.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Evertjan. wrote: Stirling wrote on 15 mei 2004 in comp.lang.javascript:
I am looking to do a password validation check using client side validation. Minimum requirement is that it must contain at least one number and one letter. (Ideally it would be of 6-20 characters in length but first things first).
I have came up with the following regEx
^(\w*(?=\w+\d+)(?=\w*[a-zA-Z])\w*)$
This works fine in IE but when testing it using NS6 it won't validate '1password', but will validate 'password1'. It seems the first forward search is consuming the first character in NS, would this be correct, and if so can anybody suggest either a way arround this or a different regular expression,
function pwTest(w){ t1 = /^[a-z\d]{6,20}$/i // only and length t2 = /[a-z]/i // at least 1 letter t3 = /\d/ // at least 1 number
return t1.test(w) && t2.test(w) && t3.test(w) }
alert(pwTest("1qweqweasd"))
My problem is that I am using ASP.net validation, so it must consist of
a singe validation expression. Is there any other way of doing this
sirt of thing with a single expression without looking forward?
SJM.
Stirling wrote on 16 mei 2004 in comp.lang.javascript : function pwTest(w){ t1 = /^[a-z\d]{6,20}$/i // only and length t2 = /[a-z]/i // at least 1 letter t3 = /\d/ // at least 1 number
return t1.test(w) && t2.test(w) && t3.test(w) }
alert(pwTest("1qweqweasd"))
My problem is that I am using ASP.net validation, so it must consist of a singe validation expression. Is there any other way of doing this sirt of thing with a single expression without looking forward?
This once more convinces me to stick to classical ASP.
Either you are wrong or ASP-net stinks.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Evertjan. wrote: Stirling wrote:
<snip> My problem is that I am using ASP.net validation, so it must consist of a singe validation expression. Is there any other way of doing this sirt of thing with a single expression without looking forward?
This once more convinces me to stick to classical ASP.
Either you are wrong or ASP-net stinks.
It does seem unlikely that ASP-net would impose such an arbitrary
restriction, but an expression could be a function call or a function
expression (that was called as - (function(){ ... })() -) so even with
this restriction there would be no limit on the amount of javascript
executed to resolve one expression.
Richard.
Richard Cornford wrote: Evertjan. wrote:
Stirling wrote:
<snip>
My problem is that I am using ASP.net validation, so it must consist of a singe validation expression. Is there any other way of doing this sirt of thing with a single expression without looking forward?
This once more convinces me to stick to classical ASP.
Either you are wrong or ASP-net stinks.
It does seem unlikely that ASP-net would impose such an arbitrary restriction, but an expression could be a function call or a function expression (that was called as - (function(){ ... })() -) so even with this restriction there would be no limit on the amount of javascript executed to resolve one expression.
Richard.
What I am using is the Validation controls which are part of the ASP.net
framework (actullay I'm using a modified version called the
DOMValidators.) These controls attach to a Textbox, and allow a regular
expression match against the text box. Yes it is limiting, but it
reduces the amount of javascript that needs coded quite a lot. So I'm
stuck with using a single validation string.
S.
On Tue, 18 May 2004 19:06:10 +0100, "Richard Cornford"
<Ri*****@litotes.demon.co.uk> wrote: Evertjan. wrote: Either you are wrong or ASP-net stinks. It does seem unlikely that ASP-net would impose such an arbitrary restriction,
It's entirely possible ASP.NET webforms stink, no seriously, they
really stink. They are almost certainly the worst thing ever to come
out of Microsoft.
but an expression could be a function call or a function expression (that was called as - (function(){ ... })() -) so even with this restriction there would be no limit on the amount of javascript executed to resolve one expression.
True, but stop shining the shite, there's no way it'll be worth it.
Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jim Ley wrote: "Richard Cornford" wrote:Evertjan. wrote: Either you are wrong or ASP-net stinks.
It does seem unlikely that ASP-net would impose such an arbitrary restriction,
It's entirely possible ASP.NET webforms stink, no seriously, they really stink. They are almost certainly the worst thing ever to come out of Microsoft.
<snip>
I am not sure why I gave Microsoft credit for not being that stupid,
they demonstrate monumental incompetence on occasions, like the fact
that I have to use a Mozilla/Gecko browser when I visit the MSDN site
because they cannot cope with the configurability of their own (IE6)
browser.
Richard. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I...
|
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: JJ |
last post by:
To validate a password as the user is registering I want to use a regular
expressio validator.
I got this one from the Microsoft web site for validating a password of at
least 7 characters, with...
|
by: =?Utf-8?B?am1obWFpbmU=?= |
last post by:
I'm trying to create a process that allows me to limit the non-alphanumeric
characters generated with the PasswordRecovery control. Specially I want to
suppress some characters for security...
|
by: =?Utf-8?B?SXZhbiBBYnJhbW92?= |
last post by:
Hi!
I need the password matching:
1. at least 6 chars
2. only English chars or numbers (no spaces and no other chars)
What is the regular expression syntax for that?
Thanks in advance.
|
by: Jon Paal |
last post by:
when user loses their password, the membership module emails a new password , the format is very complex.
how can I set the format to be simple alphanumeric - say 7 characters long ?
|
by: Bob Ross |
last post by:
I am trying to validate a password field with regular expression.
the trouble is none of the ones I find on the net seem to work.
^(?=.*\d)(?=.*)(?=.*).{4,8}$
This won't allow Hello12 which it...
|
by: Pakku |
last post by:
Hi,
Wondering if someone could point me to a piece of code that checks to
see if password being created is at least 8 char long and has a number
and a special character...
Thanks
|
by: bienwell |
last post by:
Thanks fyi.
"RhythmAddict" <sanjay.uttam@gmail.comwrote in message
news:61ef59f1-90bb-45a3-a5db-2d100a903662@59g2000hsb.googlegroups.com...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |