Topic: Validating Form Data via JavaScript (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28648" title="Pages that link to Topic: Validating Form Data via JavaScript (Page 1 of 1)" rel="nofollow" >Topic: Validating Form Data via JavaScript <span class="small">(Page 1 of 1)</span>\

 
Gothmatum
Nervous Wreck (II) Inmate

From: A place surrounded by turkeys
Insane since: Jul 2006

posted posted 11-17-2006 19:36

The latest request from my higher-ups is as follows:

We have a few order forms on the website, but when a field is left blank and the Submit button is hit, all the fields are sent to our salespeople who get rather confused/frustrated/inconvenienced by all the extraneous data. They would like the forms to leave out empty fields once they're submitted.

Can this be achieved with JavaScript?

~~~
Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 11-18-2006 10:42

Yes it can be done in JS but it's more a server side task.
In JS you could use DOM methods to remove the empty FORM elements onSubmit. Dirty but it'll work ... if the user hasn't disabled JS.

liorean
Bipolar (III) Inmate

From: Umeå, Sweden
Insane since: Sep 2004

posted posted 11-18-2006 23:13

I would consider this a task for the receiving server side page. The data collecting back end should always do validation of received data.

--
var Liorean = {
abode: "http://codingforums.com/",
profile: "http://codingforums.com/member.php?u=5798"};

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 11-19-2006 13:44

Indeed, liorean is right.

Javascript checks are an added bonus for usability - they are never something you should rely on.

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 11-19-2006 14:28

Just to make it crystal clear. I do NOT advice to do that in JavaScript. As I said, although it's possible to do on client side, this is clearly something that is best done on server side.

This should be a one line fix on your current server side script.



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu