473,804 Members | 3,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1487
"Olivia Towery" <ti*****@adelph ia.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=valida te1(),validate2 ()
or
onsubmit=valida te1()&&validate 2()

Tom
Jun 27 '08 #2
Olivia Towery wrote on 19 apr 2008 in comp.lang.javas cript:
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*****@adelph ia.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=valida te1(),validate2 ()
or
onsubmit=valida te1()&&validate 2()
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="retur n 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="retur n 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
4544
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 'Save as Incomplete' button is Clicked the form will be going to the "SaveAsincomplete.asp" without validation of the fields. And when the 'save as complete' is clicked certain fileds are to be validated and by the function return value, if false...
2
1616
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 works okay, but if it gets called onSubmit, only the first form field value gets displayed and the rest are undefined. Help! <script> function showValues() {
2
3312
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 so: <form name="XX" method="get" action="/Foo" onsubmit="onSearch(); return false;">
3
12158
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" value="" onclick="return validate_form()"> </form> where validate_form() returns true or false depending on whether the user entered a valid age.
1
5874
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, System.EventArgs e) { Button1.Attributes.Add("OnClick","fun()"); } Problem in using "Button1.Attributes.Add " for client side script for
8
6705
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 alerts when fields are not entered properly and it seems to work, except...when there are no errors, instead executing the php action script, I get a popup dialog box in IE6 asking if I want to download or run the php script. Can anyone tell me
8
6854
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
3679
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 LANGUAGE="Javascript"> <!-- Displays the name in the second textbox function displayName()
2
4778
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 I will. Let me illustrate the problem with examples. The HTML: <html> <head> <script type="text/javascript" src="/js/mootools_1_11.js"></script>
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10087
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.