?
Solved

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

Posted on 2009-03-28
3
Medium Priority
?
263 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 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

752 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