On 2 Mar 2007 13:26:43 -0800, "Larry Marburger" <lmarburger@gmail.com>
wrote:
Quote:
>On Mar 2, 12:58 pm, MattMika <mattm...@hotmail.comwrote: Quote:
>Can anyone point out the problem with this? The commented regex var
>and if statement dont work and break the GroupName check when
>uncommented. I tested the AccessCodeRegxp with preg_match and it seems
>to work fine, it just wont here. Any pointers would be great.
| >
>Matt,
>
>Could you post the string you're trying to match with AccessCodeRegxp?
|
I've been trying all kinds of combinations. This is for a form on our
customer groups admin page on our ecommerce site. The idea is to have
our people create 'access codes' that arent real easy to guess when
creating new customer groups, ie. a string 6 to 12 chars in length,
that contains one number, one lowercase letter, one uppercase letter,
and one special character - !, @, #, $, %, ^, & or *
valid codes:
@tHom3
123$aBCD
ThisCod3!
AppleC@re22
As*ixs3
I should've only posted the code below as the groupname stuff works
fine by itself, it only breaks when this 'access code' regex is
present. I've been unable to get the 'access code' regex to check
properly even though the regex works fine in preg_match.
function check_form() {
var error = 0;
var error_message = "<?php echo JS_ERROR; ?>";
var customers_group_access_code =
document.customers.customers_group_access_code.val ue;
var AccessCodeRegxp =
/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{6,12}$/;
//alert(customers_group_access_code);
if (!AccessCodeRegxp.test(customers_group_access_code ) {
error_message = error_message + "<?php echo
ERROR_CUSTOMERS_GROUP_ACCESS_CODE; ?>";
error = 1;
}
if (error == 1) {
alert(error_message);
return false;
} else {
return true;
}
}
I can see the form input with alert(customers_group_access_code);, but
this will not return an error if the code does not comply with the
regex or even when its empty.
TIA
Matt Mika