The regexes for formval.js when matching 'alpha' and
'alnum' arent quire right. below is what I used to get
what I needed working (around line 197)
if(cons['alpha'] &&
!mjs_match(value,/^([A-Za-z_\s])+$/))
{
return mjs_formValidationFailed("Value should
only contain alphabetical characters");
}
if(cons['alnum'] &&
!mjs_match(value,/^([A-Za-z0-9_\s])+$/))
{
return mjs_formValidationFailed("Value should
only contain alphanumerical characters");
}
if(cons['word'] && !mjs_match(value,/\W+/))
{
return mjs_formValidationFailed("Value contains
bad characters");
}
Logged In: YES
user_id=1162293
Thanks for reporting.
This problem was also addressed in bug #1428444. The fix
I've done gives result which differ from your suggestions:
- "alpha" does not include space and _ (underscore) characters
(this corresponds to the well known isalpha() C function)
- for the same reason, "alnum" does not include those chars
- "word" regexp only accept \w chars (your RE should ne /^\w+$/)
Hence, the new logic is:
if(cons['alpha'] && mjs_match(value,/[^A-Za-z]/))
{
return mjs_formValidationFailed("Value should only
contain alphabetical characters");
}
if(cons['alnum'] && mjs_match(value,/[^A-Za-z0-9]/))
{
return mjs_formValidationFailed("Value should only
contain alphanumerical characters");
}
if(cons['word'] && mjs_match(value,/\W/))
{
return mjs_formValidationFailed("Value contains bad
characters");
}