paymentstv Posted December 12, 2010 Share Posted December 12, 2010 Hello all, I have a php file where i have a text input box in html. I have the following code now that succesfully check if the input is letters or numbers. However, I want to include . and / in the allowed characters. Can some one please help me to modify the code so that it accepts "." and "/" Thank you. else if( channelname.search("[^A-Za-z0-9\ ]") >= 0) { alert("Only characters and numbers allowed.") ; document.getElementById( "channelname" ).focus() ; return false ; Link to comment https://forums.phpfreaks.com/topic/221433-how-to-allow-only-numbers-letters-and-in-html-input/ Share on other sites More sharing options...
BlueSkyIS Posted December 12, 2010 Share Posted December 12, 2010 the bit you posted is not php, but you might change it like this: else if( channelname.search("[^A-Za-z0-9\./ ]") >= 0) { the code is javascript and i'm not sure on javascript regex syntax. Link to comment https://forums.phpfreaks.com/topic/221433-how-to-allow-only-numbers-letters-and-in-html-input/#findComment-1146349 Share on other sites More sharing options...
paymentstv Posted December 12, 2010 Author Share Posted December 12, 2010 This worked. Thank you very much ! Link to comment https://forums.phpfreaks.com/topic/221433-how-to-allow-only-numbers-letters-and-in-html-input/#findComment-1146359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.