MDanz Posted July 23, 2010 Share Posted July 23, 2010 how do i do this?... only two words allowed to be input into textfield. Quote 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 <=. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.