473,394 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

OnSubmit using two script validations

I cannot figure out how to complete two script validations onsubmit. Only
the first one listed runs. If anyone knows how to do this, please help.

--
Olivia Towery
Jun 27 '08 #1
3 1468
"Olivia Towery" <ti*****@adelphia.netwrote
>I cannot figure out how to complete two script validations onsubmit. Only
the first one listed runs. If anyone knows how to do this, please help.
onsubmit=validate1(),validate2()
or
onsubmit=validate1()&&validate2()

Tom
Jun 27 '08 #2
Olivia Towery wrote on 19 apr 2008 in comp.lang.javascript:
I cannot figure out how to complete two script validations onsubmit.
Only the first one listed runs. If anyone knows how to do this,
If you mean input validation,
yes, we know, Olivia,
Show us your code, [and possible errorlines]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #3
Tom de Neef wrote:
"Olivia Towery" <ti*****@adelphia.netwrote
>I cannot figure out how to complete two script validations onsubmit. Only
the first one listed runs. If anyone knows how to do this, please help.

onsubmit=validate1(),validate2()
or
onsubmit=validate1()&&validate2()
This is _not_ the proper way as validation will be performed but form
submission will take place even if validation fails.

Furthermore, in both cases the attribute value would have to be quoted, due
to the characters `(', `)', `,', and `&' in it:

http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2

Should be:

<form action="..." ...
onsubmit="return validate1(this) && validate2(this)">

If either validation fails, it should return `false' so that the boolean
expression evaluates to `false', which is returned to the event handler and
causes the form not to be submitted.

Another way that is a little bit easier to maintain:

function validate(f)
{
return validate1(f) && validate2(f);
}

<form action="..." ... onsubmit="return validate(this)">

Passing the `this' value saves one from having to look up the form object
reference in either validation method again.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
2
by: Eric Petzold | last post by:
This is a small excerpt of a larger script, but it is creating alot of frustration. I am trying to query the vaule of a hidden form field via onSubmit... if the function gets called out-right it...
2
by: OtisUsenet | last post by:
Hello, I am trying to call Javascript from FORM's onSubmit, and return false, so the form is not actually submitted. Normally I can just add 'return false;' to onSubmit to accomplish this, like...
3
by: n3mtkj3mzsir0cy | last post by:
I have created web pages that do client-side form validation using the onclick directive. E.g., <form action=other_page.cgi method=post> Enter your age: <input name=age> <input type="submit"...
1
by: Anup | last post by:
In my form I and doing validations using 'Javascript' as I m using ASP1.1 and there is very less support for Validators there. //Code Behind private void Page_Load(object sender,...
8
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends...
8
by: Mark Livingstone | last post by:
I have a form that uses the following: onSubmit="some_var = 'validated';" FireFox is OK with that. Internet Explorer isn't. any ideas why? Thanks.
2
by: yen31 | last post by:
I noticed that the onclick event works but the onsubmit doesn't why is it ? Below is the code of my form. Please help me resolve this issue. <html> <head> <title>Form</title> <SCRIPT...
2
by: rudiedirkx | last post by:
Gents, I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/answers/166542-onsubmit-safari but not as detailed as...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.