Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A twist on form validation

Status
Not open for further replies.

tiamat2012

Programmer
Joined
Dec 12, 2004
Messages
144
Location
US
Hey all,

My client has requested that I allow certain symbols in the forms. The only problem is I'm using php to connect to a database, so if I insert these symbols (like a ") it will mess everything up.

My solution is to change the code to special characters (like instead of a " mark it would be " so it is displayed the same way but not processed in the php.

I would like to do this on the "onClick" of the submit button, rather than doing it as they type because I don't want to insert random text into what they're saying (like I could use an onKeyDown)

Does anyone have a good basis for doing this or any useful functions that would help?

-Kerry
 
Personally, I'd do this server-side in PHP.

Pros:

- If JavaScript is disabled, it still works
- PHP has built-in routines to do this, AFAIK

Cons:

- None.

I'd ask in the PHP forum for more on this.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Ahh ok cool, thank you. I just realiezd I had the misconception that it wouldn't properly submit to another page because of the symbols (like if it had "s in it), but realize that is only a problem when turn it into a string.

I'll check that out.

-Kerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top