Solved

Can I include 2nd and subsequent validation calls in OnSubmit?

Posted on 2009-03-28
3
249 Views
Last Modified: 2012-05-06
I have a javascript routine which works fine when calling from onSubmit.
This call only validates one field as I have to pass the field id (this.EDD).

Could I make a second call within this same onSubmit to another date field I want to validate?  How would I do that?

RGC
onSubmit="return checkdate(this.EDD);"

Open in new window

0
Comment
Question by:coleventures
3 Comments
 
LVL 30

Accepted Solution

by:
third earned 500 total points
ID: 24012439
create a wrapper function,


function validate(obj){
  return checkdate(obj.EDD) && checkdate(obj.EDD2);   //i named the second date field as EDD2
}



then change your onsubmit call to,

onSubmit="return validate(this);"
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24012814
It is also possible to place additional code within the handler:
// Or, validate multiple items.
onSubmit="return checkdate(this.EDD) && checksomething(this.something);"
 
// Do something and then validate date.
onSubmit="somethingElse(this.EDD); return checkdate(this.EDD);"

Open in new window

0
 
LVL 3

Author Closing Comment

by:coleventures
ID: 31563980
Your solution is the better all around answer.  It was also the first.
It works best for multiple booleans meant for onSubmit and allows the onSubmit command to stay uncomplicated.  I was looking for that ability to have two or more conditions that only returned true when all conditions were true and it seems that && (the way to represent logical AND) is the correct way to do it.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Where is java script information saved? 2 54
Checking data with javascript 3 19
Client Validating 2 date fields, required & comparison 1 28
asp.net mvc5 6 17
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question