Hi guys,
I need to check if user enter only alphabet, numeric, hypen and underscore like "mark_thien-01", "markthien" or "mark0" or "mark_1" is valid. Appreciate any help please.
Thanks & Regards,
Mark Thien
how to accept input with only alphabet, numeric, hypen and u
Moderator: General Moderators
Re: how to accept input with only alphabet, numeric, hypen and u
Regular expression.
Code: Select all
if (preg_match('/[^\w-]/', $string)) {
// invalid
} else {
// valid
}Re: how to accept input with only alphabet, numeric, hypen and u
thanks a lot man .... it works a like charm ! I love you !