473,401 Members | 2,139 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,401 software developers and data experts.

dynamic function not attaching to event

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 onsubmit handler
then it does work.

Here's the problem page:

http://www.tobymiller.com/js/validation.htm

Any ideas?

-tm

Jul 23 '05 #1
1 1529
Toby Miller wrote:
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.
No. BTW: It is the `submit' event and the `onsubmit' event handler.
the result of that function (true/false) should then be returned to
pass or fail the submission of that form.
Yes, but there is no result, e.g. the return value of that function is
`undefined'.
[...]
http://www.tobymiller.com/js/validation.htm

Any ideas?


Your source code reads

| <form name="myform" onsubmit="alert('inline');"
| action="/js/validation.htm">

After the document has been loaded, document.forms[0].onsubmit yields

function onsubmit(event)
{
alert("inline");
}

You do not return a value to the `onsubmit' event handler, so submission
will never be canceled. You have to use the `return' keyword within the
event listener (here: the attribute value): return `false' to cancel
submission, `true' to allow it. This is accomodated best by returning
the result of a boolean function that is passed a reference to the form:

<form ... onsubmit="return checkForm(this);">

Note that if client-side scripting is not supported or is disabled, the
form is submitted always, so additional server-side tests are a must.
PointedEars
Jul 23 '05 #2

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

Similar topics

1
by: Christoph | last post by:
newFieldElement = document.createElement( 'INPUT' ); newFieldElement.onblur = new Function( "calculatePremiumOptionTotal( this );" ); In my (dynamically generated) javascript, I've never had a...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
0
by: Jan Klat via .NET 247 | last post by:
I have large webform with many dynamic controls. Here is theissue: At some state I am programaticlly adding rows to table. Firstcell of row contains ImageButton. I am attaching command eventto...
1
by: pbb | last post by:
I'm creating a set of dynamic controls on a webpage by calling my BuildControls sub in the Page_Init sub. I recreate the controls by calling the BuildControls sub in the LoadViewState override...
2
by: Ron M. Newman | last post by:
Hi, Just need a little advice. Id like to build *dynamic* context menus for tree nodes. I'm pretty versed in building context menus and attaching them to tree nodes. My question is, what...
7
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
1
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...
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...
0
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...

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.