473,796 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function not called from onsubmit code

I have some code comprising the onsubmit attrribute of a form. The code is
executing, but apparently a function called as the last statement is not
executed. The form content is submitted to the server. The behavior is the
same in Firefox and IE (current Windows versions). The following is
excerpted from the browser's "View source":

<script type="text/javascript">
function verify(f)
{
var msg;
var empty_fields = "";
var unselected = "";
var selected = 0;
alert('In verify()'); // not executed
// ...
}
</script>

<form name="ccform" id="ccform" method="post" action="/admin/index.php"
onsubmit="
alert('In onsubmit 1'); // executed
this.type.oneRe quired = true;
this.donationty pe.oneRequired = true;
this.fname.requ ired = true;
this.lname.requ ired = true;
this.email.requ ired = true;
alert('In onsubmit 2'); // executed
return verify(this);
">

--
For mail, please use my surname where indicated:
st***@surname.r eno.nv.us (Steve Brecher)
Jul 8 '06 #1
3 4173
Steve Brecher wrote on 08 jul 2006 in comp.lang.javas cript:
I have some code comprising the onsubmit attrribute of a form. The
code is executing, but apparently a function called as the last
statement is not executed. The form content is submitted to the
server. The behavior is the same in Firefox and IE (current Windows
versions). The following is excerpted from the browser's "View
source":

<script type="text/javascript">
function verify(f)
{
var msg;
var empty_fields = "";
var unselected = "";
var selected = 0;
alert('In verify()'); // not executed
// ...
}
</script>

<form name="ccform" id="ccform" method="post"
action="/admin/index.php"
onsubmit="
alert('In onsubmit 1'); // executed
It fails in these 5 lines below
this.type.oneRe quired = true;
this.donationty pe.oneRequired = true;
this.fname.requ ired = true;
this.lname.requ ired = true;
this.email.requ ired = true;
or, deleting them the 3rd alert is shown.
alert('In onsubmit 2'); // executed
return verify(this);
">
<input type=submit>
</form>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 8 '06 #2
"Steve Brecher" <see.signature@ endwrites:
<script type="text/javascript">
function verify(f)
{
var msg;
var empty_fields = "";
var unselected = "";
var selected = 0;
alert('In verify()'); // not executed
None of these lines can fail.
// ...
You have omitted lines here. If one of these lines has a syntax
error, then the entire function declaration fails, and no function
named "verify" is available to be called later.

What errors does the javascript console show?

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 8 '06 #3
Lasse Reichstein Nielsen <lr*@hotpop.com wrote:
You have omitted lines here. If one of these lines has a syntax
error, then the entire function declaration fails, and no function
named "verify" is available to be called later.

What errors does the javascript console show?
It shows a syntax error. Thanks! (Obviously I'm inexperienced with js.)

--
For mail, please use my surname where indicated:
st***@surname.r eno.nv.us (Steve Brecher)
Jul 8 '06 #4

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

Similar topics

3
4542
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...
1
1963
by: Dwayne Epps | last post by:
This is probably a no brainer, but I am having no luck at getting this to work. I'm creating functions that will validate form data fields. For example, the following function: function checkText(field, msg, min, max) { if (!min) { min = 1 } if (!max) { max = 65535 } if (!field.value || field.value.length < min || field.value.max > max || !field.value.match(/^*$/)) { alert(msg);
2
1625
by: Marc | last post by:
Hello, I have a form. On submit I want a javaScript to check if any fields are filled in and if so, if the fields that correspond to the filled - in fields are also filled in. I wrote a js function which gets called onSubmit. But I don't have the change to see if the js I wrote works because the script doesn't even get called - I put an alert('test'); in the first line of the function definition but after a submit there's no alert:
2
2479
by: Justin Koivisto | last post by:
This is probabally a basic question, but I don't quite understand what is going on with this... Say I have a variable called "myObject" which is an object created from a class I wrote. The class has a method called "testing". When I submit a form, I want to call it: <form onsubmit="myObject.testing()" ... When I click the submit button for the form, I get the following
1
1557
by: Toby Miller | last post by:
I have this form validation that I'm trying to build, but it's not working properly. A dynamic function to the onsubmit event for a form. the result of that function (true/false) should then be returned to pass or fail the submission of that form. What is happening is that in Firefox and IE returning false doesn't stop the form submission. In IE the dynamic function just doesn't work. If I attach a smaller dynamic function to the form...
8
2077
by: bdobby | last post by:
Hi. I am relatively new to js, but I did think I was starting to get the hang of it. Then this happened... I have a form with an onsubmit event handler: <form id="uploadForm" method="post" action="..." onSubmit="checkDates()"> The event handler does some minor validation, then returns true or
10
6092
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get different results than when I use a javascript submit: form1.submit();. I think the javascript submit is working as it should, since I want the server to process an __EVENTTARGET posting. When I click the submit button, it does not process the...
13
7818
by: Steve | last post by:
On page 392 of "Javascript the definitive guide" a function is called like this:- <form action="processform.cgi" onsubmit="return validateForm();"> Why, in this instance, is the return statement used in calling the function validateForm rather than being included inside the function? Thanks in advance,
13
3615
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at this time (in fact, I don't even know if it totally works, I'm still debugging). However, the first problem is that when an error is encountered, I get my alert box, I press ok and then the form is submitted and the new data is entered into the...
0
9524
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
10217
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...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
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...
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.