cluce Posted June 19, 2007 Share Posted June 19, 2007 does anybody know how to check for blank spaces? I dont just mean blank, blank but actual spacebar spaces. ive tried is_null and !isset and neither one works?? Link to comment https://forums.phpfreaks.com/topic/56227-solved-how-to-check-for-blank-spaces-in-a-text-field/ Share on other sites More sharing options...
per1os Posted June 19, 2007 Share Posted June 19, 2007 <?php $textfield = isset($_POST['textfield'])?trim($_POST['textfield']):''; if (empty($textfield)) { echo 'The text field is empty'; } ?> Trim the data www.php.net/trim Link to comment https://forums.phpfreaks.com/topic/56227-solved-how-to-check-for-blank-spaces-in-a-text-field/#findComment-277696 Share on other sites More sharing options...
cluce Posted June 19, 2007 Author Share Posted June 19, 2007 I am trimming the data which didnt work but I never tried the empty function. Link to comment https://forums.phpfreaks.com/topic/56227-solved-how-to-check-for-blank-spaces-in-a-text-field/#findComment-277713 Share on other sites More sharing options...
obsidian Posted June 19, 2007 Share Posted June 19, 2007 I am trimming the data which didnt work but I never tried the empty function. isset() on a text field will always return true since the empty string is a legitimate value. empty() on the other hand, will return false if the value of the variable is equivalent to an empty string. So, empty() would actually return your desired results with or without trimming. Link to comment https://forums.phpfreaks.com/topic/56227-solved-how-to-check-for-blank-spaces-in-a-text-field/#findComment-277748 Share on other sites More sharing options...
cluce Posted June 19, 2007 Author Share Posted June 19, 2007 thanks for clearing that for me .. Link to comment https://forums.phpfreaks.com/topic/56227-solved-how-to-check-for-blank-spaces-in-a-text-field/#findComment-277750 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.