Solved

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

Posted on 2009-03-28
3
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

733 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