Menu

#5 'Word' match not working properly

open
None
5
2006-02-10
2006-02-09
Anonymous
No

When trying to perform form validation with the type
'word', the regex incorrectly fails unless the input
string is either a single 'word' character or multiple
'word' characters and a space (I have NO idea why it
works when you add a space).

If you change the regex in line 201 of formval.js from
/\W/ to /^\w+$/, it seems to work as intended.

201: if(cons['word'] && !mjs_match(value,/^\w+$/))

Hope this helps,

John F. Zmrotchek
john.zmrotchek@morganstanley.com

Discussion

  • Herve Masson

    Herve Masson - 2006-02-10
    • assigned_to: nobody --> rvmindstep
     
  • Herve Masson

    Herve Masson - 2006-02-10

    Logged In: YES
    user_id=1162293

    Thanks for issuing this bug report.

    Actually, not only the 'word' mode is broken; 'alpha' and
    'alnum' are also unfunctional due to a wrong logic in
    testing the matching code:

    if(cons['word'] && !mjs_match(value,/\W/))

    should have been:

    if(cons['word'] && mjs_match(value,/\W/))

     

Log in to post a comment.