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!

Data validation

Status
Not open for further replies.

Bobnz

IS-IT--Management
Joined
Aug 19, 2002
Messages
116
Location
NZ
Hi, I have a postgresql database with a web interface and I need to check that the data being entered is valid for the field. I would like to be able to do this before submitting the form so the user can make any changes without having to fillout and resubmit the form. This is a small database so performance is not an issue.

thanks in advance
Bob
 
two approaches

1. client side - use javascript to validate the data (what exactly do you mean by validate? empty field, check for data types? regex only allowable characters?)

weaknesses - not every one had js turned on, easy to defeat, cross browser issues

2. validate on server - again what is validate?
The trick to avoid the user filling out the form again, is to place the form in a function and use the value
Code:
<input type=text name=fname value="<?=$fname?>">
attribute of the element to indicate a value...when the page first opens the value variable has no value and nothing is shown in the box. After the form is submitted those form elements are passed to serverside vars (ie $fname) and can be passed to the function to 'store' the value...items that do no validate properly can be blanked, or unset and not passed back...


Bastien

Cat, the other other white meat
 
Thanks bastienk for the reply.

Could you elaborate on the server side validation.I need to check datatype and wether dates are <Now()||>Now(), name fields less <3. Also if some fields have been spelt properly like months, I thought to use a swith statement for that.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top