I have created web pages that do client-side form validation using the
onclick directive. E.g.,
<form action=other_pa ge.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.
This does what I want almost everywhere (e.g., Firefox on FreeBSD,
Safari on Mac, IE on Win2000) but recently I have become aware of an
exception: IE on WinXP.
On WinXP's IE, validate_form() is called (and will display an alert box
if that's that's what I coded), but whether it returns true or false,
the form is submitted. (Then we do the server-side validation and throw
up an error page, but I'd rather catch this client-side.)
So the question I have is: why is WinXP so weird about this? Previous
versions of IE didn't do this.
While looking into this, I've discovered I can also do an onsubmit check
in the form tag, e.g.,
<form action=other_pa ge.cgi method=post onsubmit="retur n
validate_form() ">
Is onsubmit new or has it been around for a while? Can I trust old
Mozillas on Linux to do the right thing with it? Windows is actually a
small portion of the target audience, but I like to make things work for
everyone.
Does it make a difference if the form is submitted to the same page or a
different page? I don't have ready access to Windows XP to test this
out. 3 12155 n3************* @jetable.org wrote: I have created web pages that do client-side form validation using the onclick directive. E.g.,
<form action=other_pa ge.cgi method=post> Enter your age: <input name=age> <input type="submit" value="" onclick="return validate_form() "> </form>
That form could be submitted without the user clicking on the submit button.
You're better off using onsubmit.
Is onsubmit new or has it been around for a while?
From the 1999 HTML specification: http://w3.org/TR/html4/interact/scripts.html#h-18.2.3
--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is n3************* @jetable.org wrote:
<snip> <form action=other_pa ge.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.
This does what I want almost everywhere (e.g., Firefox on FreeBSD, Safari on Mac, IE on Win2000) but recently I have become aware of an exception: IE on WinXP.
<snip> While looking into this, I've discovered I can also do an onsubmit check in the form tag, e.g.,
<form action=other_pa ge.cgi method=post onsubmit="retur n validate_form() ">
Is onsubmit new or has it been around for a while?
onsubmit has been around for longer than support for onclick handlers on
submit buttons.
Can I trust old Mozillas on Linux to do the right thing with it?
Depending on what you mean by "the right thing", probably. In general,
when the _user_ submits a form (by any available mechanism for the task,
but not necessarily when a form is submitted by a script) a javascript
capable user agent will call the form's onsubmit handler(s) and allow
them to cancel the submission when necessary. The onsubmit handler is
the _only_ recommendable trigger for form validation.
Windows is actually a small portion of the target audience, but I like to make things work for everyone.
<snip>
Form validation is probably the one area of browser scripting where all
user agents (at least those that understand what a form is and allow
them to be scripted) can be accommodated with a signal (non
feature-branching) script.
Richard.
David Dorward <do*****@yahoo. com> wrote: n3************* @jetable.org wrote:
I have created web pages that do client-side form validation using the onclick directive. E.g.,
<form action=other_pa ge.cgi method=post> Enter your age: <input name=age> <input type="submit" value="" onclick="return validate_form() "> </form>
That form could be submitted without the user clicking on the submit button. You're better off using onsubmit.
This is true. The browsers I had been working with fired off the
onclick handler even if the submit button wasn't actually clicked,
though. That may be technically wrong, but that's what they did.
I'm still curious about the behavior of WinXP's IE. I click on the
button, and the onclick handler fires off, and returns false, but the
form is submitted anyway. Isn't that wrong? Is WinXP's IE following
some specification that all those other browsers aren't aware of, or is
Microsoft just wrong here? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bnp |
last post by:
Hi All,
I am quite new the JavaScript. Basically I am a C++ programmer, but
now I am working on JavaScript since last 5 days.
I have a problem regarding the form validation.
I have created a script that validates the form fields. the validation
procedure is called ONCLICK event of the submit button.
Follwowing is the structure of the validation procedure.
|
by: x muzuo |
last post by:
Hi guys,
I have got a prob of javascript form validation which just doesnt work
with my ASP code. Can any one help me out please.
Here is the code:
///////////////////////////////////////////////
<%
ntlogon = (Request.ServerVariables("LOGON_USER"))
|
by: webbedfeet |
last post by:
Hi
I hope someone can help me. I have a client side form validation script
which works perfectly in IE but clicking "Submit" in Mozilla does
nothing - the form won't submit.
Is there something I can use that will work for both browsers, or is
there something wrong with my code? I seem to think that the problem
lies with the "onclick" area of the form.
This is my code, such as it is...
<SCRIPT LANGUAGE="JavaScript">
|
by: Nick Bell |
last post by:
I have a general form validation question. I know very little about
javascript, a little more about PHP. Using yav (http://yav.sourceforge.net):
<form method="POST" name=edit onsubmit="return performCheck('edit', rules,
'classic');" action="pages_edit_submit.php">
<input type="text" name="title">
<input type="submit" name="Save">
<input type="submit" name="Cancel">
</form>
|
by: iam247 |
last post by:
Hi
In my prototype asp page (with no javascript and no password
validation, I have a registration form with the following action:
<form name="form" method="post" action="RegDetails.asp">
This works fine, the form details are collected by RegDetails.asp
I am attempting to include javascript server side validation for the
| |
by: julie.siebel |
last post by:
Hello all!
As embarrassing as it is to admit this, I've been designing db driven
websites using javascript and vbscript for about 6-7 years now, and I
am *horrible* at form validation.
To be honest I usually hire someone to do it for me, grab predone
scripts and kind of hack out the parts that I need, or just do very
minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
|
by: this one |
last post by:
I have the following code
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="..\include\gen_validatorv2.js"
type="text/javascript"></script>
</head>
|
by: Chris |
last post by:
Hi,
I have a form for uploading documents and inserting the data into a mysql
db. I would like to validate the form. I have tried a couple of Javascript
form validation functions, but it appears that the data goes straight to the
processing page, rather than the javascript seeing if data is missing and
popping up an alert. I thought it may be because much of the form is
populated with data from the db (lists, etc.), but when I leave...
|
by: plumba |
last post by:
Ok, another problem... A bit querky this one..
My form calls an onsubmit function to check fields for completion (validation check).
Here is a breakdown version of the form:
<html>
<script>
function toggle_display() {
var form = document.getElementById('hidesubmit');
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |