View Full Version : [Help] PHP
ThisNameWillDo!
29-12-2009, 09:03 PM
Hey, I'm making a register form, and I don't want the user's first name or last name to be able to contain numbers. How can I make it check if they've entered numbers in a field using PHP? Any help +rep if I can. I've used Google, no joy, so please don't just say use Google.
Thanks,
Vince.
RichardKnox
29-12-2009, 09:39 PM
Just using a preg_match on the string should do the trick.
<?php
if(preg_match('/[0-9]/', $string)) {
echo 'error message here';
}
?>
ThisNameWillDo!
29-12-2009, 09:52 PM
Just using a preg_match on the string should do the trick.
<?php
if(preg_match('/[0-9]/', $string)) {
echo 'error message here';
}
?>
That works perfectly, thanks a lot! +Rep.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.