depojones Posted April 26, 2010 Share Posted April 26, 2010 Hi all, How do I output an error if my input contains any whitespace and special characters. for instance, <script>, <object>, etc Link to comment https://forums.phpfreaks.com/topic/199823-special-characters-validation/ Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 regular expressions are what you need (google them). But for example, if you want to make sure a string only contains letters and numbers: if(!preg_match('/^[A-Za-z0-0]*$/', $string)) { //if contained special characters } You can use that Link to comment https://forums.phpfreaks.com/topic/199823-special-characters-validation/#findComment-1048877 Share on other sites More sharing options...
Psycho Posted April 26, 2010 Share Posted April 26, 2010 You need to be more explicit on "special characters". You can either specify specific characters NOT to allow or specify the characters that ARE allowed. Link to comment https://forums.phpfreaks.com/topic/199823-special-characters-validation/#findComment-1048879 Share on other sites More sharing options...
depojones Posted April 26, 2010 Author Share Posted April 26, 2010 This is exactly what am looking for. Thanks for your contribution Link to comment https://forums.phpfreaks.com/topic/199823-special-characters-validation/#findComment-1048889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.