MDanz Posted July 23, 2010 Share Posted July 23, 2010 how do i do this?... only two words allowed to be input into textfield. Link to comment https://forums.phpfreaks.com/topic/208622-limit-two-words-in-textfield/ Share on other sites More sharing options...
Alex Posted July 23, 2010 Share Posted July 23, 2010 if(str_word_count($_POST['field'], 0) == 2) { // contained only 2 words } else { // did not contain 2 words } str_word_count If you mean two words at max eg 0, 1, or 2, change the comparison operator == to <=. Link to comment https://forums.phpfreaks.com/topic/208622-limit-two-words-in-textfield/#findComment-1089913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.