codrgii Posted August 22, 2009 Share Posted August 22, 2009 how do i check in php if someone has posted at least 1 capital as their input and if they haven't then exit(); ? Link to comment https://forums.phpfreaks.com/topic/171381-capital-check/ Share on other sites More sharing options...
corbin Posted August 22, 2009 Share Posted August 22, 2009 Hrmmm two ways come to mind: if(strtolower($input) == $input) { //invalid } if(!preg_match('/[A-Z]/', $input)) { //invalid } Link to comment https://forums.phpfreaks.com/topic/171381-capital-check/#findComment-903825 Share on other sites More sharing options...
Garethp Posted August 22, 2009 Share Posted August 22, 2009 if(!preg_match('~([A-Z]|exit\(\)~',$input)) { //Has no capitals, and/or contains exit(); } Link to comment https://forums.phpfreaks.com/topic/171381-capital-check/#findComment-903843 Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 if(!preg_match('~([A-Z]|exit\(\)~',$input)) { //Has no capitals, and/or contains exit(); } Ha! I think you misread the question. Link to comment https://forums.phpfreaks.com/topic/171381-capital-check/#findComment-903846 Share on other sites More sharing options...
Garethp Posted August 22, 2009 Share Posted August 22, 2009 Oh... woops if(!preg_match('~[A-Z]~', $input)) { exit(); } Link to comment https://forums.phpfreaks.com/topic/171381-capital-check/#findComment-903847 Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 Oh... woops if(!preg_match('~[A-Z]~', $input)) { exit(); } Which is now exactly what corbin posted 3 replies ago. Well done. Link to comment https://forums.phpfreaks.com/topic/171381-capital-check/#findComment-903851 Share on other sites More sharing options...
codrgii Posted August 22, 2009 Author Share Posted August 22, 2009 pardon but i forgot to mention how would i check to see if the user input contains at least one capital,one number and one lowercase? would it be like if(!preg_match('~[A-Za-z0-9]~', $input)) Link to comment https://forums.phpfreaks.com/topic/171381-capital-check/#findComment-903869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.