Jump to content

Cleaning forms


Mutley

Recommended Posts

I want to stop people inserting characters into forms (such as !"£$%^&*()><?.,).

 

What's the best way of doing this? Can I stop them from doing it to return a message, or is it better to just wipe the characters before inserting into a database, or both?

 

The only symbols I need is for an e-mail field, which are  . - @    otherwise it's just numbers 0-9 and letters A-Z. I found a script to disable input but it doesn't stop people from finding other ways of inputting bad characters.

 

Assistance would be appreciated, thanks.

Link to comment
https://forums.phpfreaks.com/topic/47038-cleaning-forms/
Share on other sites

you could use a function that checks all characters onChange()

function badChar()
{
   var textstr = document.getElementById("inputText").value;
   preg_match it for bad characters
   if (bad characters found)
   {
   alert ("dont enter bad characters and try again");
   document.getElementById("inputText").value=""; 
   }
}

Link to comment
https://forums.phpfreaks.com/topic/47038-cleaning-forms/#findComment-229388
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.