This is my newest solution on form submit data validation. it was developed in a "developer point of view" rather than "end user point of view". so if you don't have any idea about php development then you'll find it bit difficult to understand. but once you got to know the pattern u'll be loving it and of course you'll be using it to validate all your form submissions.
first we'll see what type of things do we have to validate as HTML form elements.
- textfield
- textarea
- checkbox
- radio button
- radio group
- List / Menu
- file field
and with respect to all these fields what we should thoroughly take care of is not letting users submit any values containing <SCRIPT> tags, <STYLE> tags and any other undefined strings.
and one other cool feature of this script is that you can keep the default values of other elements even though one element fail to validate. and it may sounds like a very common and lazy task with javascript enabled pages but remember this snippet will validate and keep the default values nicely even without no javascript at all.
does that sounds interesting?
No comments:
Post a Comment