I have a form without a submit button like:
<form name="form1" action=""
onsubmit="alert ('submit ' + this.name);">
<div>
<label>Field 1: <input type="text" name="field1"
onchange="alert (this.name + '=' + this.value);"></label></div>
<label>Field 2: <input type="text" name="field2"
onchange="alert (this.name + '=' + this.value);"></label></div>
</form>
The form field 'change' event handlers actually perform AJAX
submission and update some part of the page without "navigating away".
Using the exact form I've given the different browsers behave
differently in handling the default action event (pressing the Enter
key), for example using Mozilla pressing Enter in a field doesn't
cause form submission, but Safari submits the form. I've found
Mozilla submits the form in response to pressing Enter if there's
only one visible field, also:
<form name="form1" action=""
onsubmit="alert ('submit ' + this.name);">
<div>
<label>Field 1: <input type="text" name="field1"
onchange="alert (this.name + '=' + this.value);"></label></div>
</form>
Is it possible to detect the form is being submitted in response to
the default action event?
--
Stanimir 6 5078
Stanimir Stamenkov wrote:
Using the exact form I've given the different browsers behave
differently in handling the default action event (pressing the Enter
key), for example using Mozilla pressing Enter in a field doesn't cause
form submission, but Safari submits the form. I've found Mozilla
submits the form in response to pressing Enter if there's only one
visible field, also:
I don't have access to Safari, but returning false from onSubmit on the
form doesn't do the trick for you (ie. does not submit the form)? Since
obviously as you don't have submit button, you do not want an old
fashioned submit to happen, right?
Regards, Tumi
Wed, 19 Mar 2008 12:07:33 +0200, /Tuomo Tanskanen/:
I don't have access to Safari, but returning false from onSubmit on the
form doesn't do the trick for you (ie. does not submit the form)? Since
obviously as you don't have submit button, you do not want an old
fashioned submit to happen, right?
The form is still submitted but through an AJAX library (in response
to field 'change' change events, in my case). Unconditionally
returning false from 'submit' handler prevents the library from working.
--
Stanimir
Stanimir Stamenkov wrote:
Wed, 19 Mar 2008 12:07:33 +0200, /Tuomo Tanskanen/:
>I don't have access to Safari, but returning false from onSubmit on the form doesn't do the trick for you (ie. does not submit the form)? Since obviously as you don't have submit button, you do not want an old fashioned submit to happen, right?
The form is still submitted but through an AJAX library (in response to
field 'change' change events, in my case). Unconditionally returning
false from 'submit' handler prevents the library from working.
Yes, but doing it like
<form action="fallbac k.php" method="post" onSubmit="yourA jaxHandler();
return false;">
or even
<form action="fallbac k.php" method="post" onSubmit="retur n
yourAjaxHandler ();">
and having your handler return false does exactly what you want.
Regards, Tumi
Wed, 19 Mar 2008 17:57:52 +0200, /Tuomo Tanskanen/:
Yes, but doing it like
<form action="fallbac k.php" method="post" onSubmit="yourA jaxHandler();
return false;">
or even
<form action="fallbac k.php" method="post" onSubmit="retur n
yourAjaxHandler ();">
and having your handler return false does exactly what you want.
The problem is I don't fully control the generated HTML code as it
is a JSF/RichFaces [1] application. The generated code looks
something like:
<form ...>
...
<input type="text" ... onchange="A4J.A JAX.Submit(...) ;" ... />
...
</form>
I've solved my problem adding a 'keydown' handler (I can do that):
<form ...>
...
<input type="text" ...
onkeydown="retu rn preventDefault( event, this);"
onchange="A4J.A JAX.Submit(...) ;" ... />
...
</form>
Where the 'preventDefault ' function definition is:
function preventDefault( evt, fld) {
if (!evt) {
evt = event;
}
if (evt.keyCode == 13) {
fld.blur();
fld.focus();
return false;
}
return true;
}
The blur-focus thing causes a 'change' event even in the browsers
which don't normally fire it when Enter gets pressed.
[1] http://labs.jboss.com/jbossrichfaces/
--
Stanimir
Wed, 19 Mar 2008 21:49:35 +0100, /Thomas 'PointedEars' Lahn/:
Stanimir Stamenkov wrote:
>I have a form without a submit button [...]
That is a Bad Thing, ...
(TM)... Unfortunately I'm not the one requiring the given thing and
I'm not in full control of the content as I'm using some application
framework which generates most of it.
><form name="form1" action="" onsubmit="alert ('submit ' + this.name);">
... especially as you use the `onsubmit' intrinsic event handler attribute
which requires a submit button.
I've used 'onsubmit' in my example only for testing purposes. In my
real page there's no such attribute. You may see my last reply to
Tuomo Tanskanen in this thread for my solution.
--
Stanimir
Thu, 20 Mar 2008 00:23:20 +0100, /Thomas 'PointedEars' Lahn/:
Stanimir Stamenkov wrote:
>I've used 'onsubmit' in my example only for testing purposes. In my real page there's no such attribute. You may see my last reply to Tuomo Tanskanen in this thread for my solution.
That only seems to be a solution. It will not work in 11% of user agents
at the minimum, and it will annoy the rest of the users. Needlessly. Can
your client afford to lose that many potential customers, the security issue
aside? I doubt it.
Could you elaborate more on what "will not work in 11% of user
agents" (and which ones)? What security issue do you see?
--
Stanimir This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dogu |
last post by:
Noob alert.
Code is below.
File is saved as a .php.
What I'm trying to do:
User uses 'select' box drop down list to pick a value.
Value ($site) is derived from a db query. This works fine.
Value selected is used as the 'where' clause of the 2nd query.
If $site is a single word, the 2nd query works like a charm.
If $site is more than one word (has spaces), the query returns a null
|
by: Shannon |
last post by:
Hi everyone,
I am trying to post some data to a form using the XMLHTTP object, and have run into a problem trying to find the proper
location of the receiving page.
The form points to a directory, like so:
<form action="/servlet/Login" target="_top" method="POST" enctype="x-www-form-encoded" onSubmit='return goodform()'>
but the XMLHTTP object requires a specific file reference.
|
by: Pete |
last post by:
I have form/select which executes a function using onchange. No
problem. However, when I validate the page with a strict HTML 4.01
doctype at http://validator.w3.org, it demands either an action or a
method for the form?.
If I give it an empty action <form action="" ..... it validates OK. Is
this acceptable or is there a better/standards correct way?
Thanks.
|
by: Richard Cornford |
last post by:
I am interested in hearing opinions on the semantic meaning of FORM
(elements) in HTML.
I have to start of apologising because this question arose in a context
that is not applicable to the Internet. Specifically, marking up a
document that will contain multiple related form controls (intended
exclusively for client-side scripting) that would never be intended to
be submitted. I realise that that concept is a non-starter in an
Internet...
|
by: anonieko |
last post by:
Scenario: You have a page that is TOO slow to refresh.
But it allows partial flushing of html contents. I.e.
Submit button already appears but you don't
want your users to click on it prematurely
because other parts are still coming.
Here I put a javascript the will enable only
submit button only after 5 seconds after the page
is load fully.
| |
by: Steve Last |
last post by:
Hi all,
I’m using IIS6 for our college Intranet and I’m having trouble using
Request.Form. Here is my code:
<%
If Request.QueryString("action") = "show" Then
Response.Write "title: " & Request.Form("NewsTitle") & "<br />"
End If
%>
|
by: whyyyy |
last post by:
The script below works fine if the form is filled out and submitted.
But a (blank) e-mail is sent whenever the page loads, even when the form is
not submitted. I would like to receive the e-mail only when the form is
submitted
<%@LANGUAGE="VBSCRIPT"%>
<%
Set MyMail=CreateObject("CDO.Message")
|
by: yawnmoth |
last post by:
Say I have the following HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<form action="">
|
by: chromis |
last post by:
Hi,
I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following:
- Bean (Contact.cfc)
- Data Access object (ContactDAO.cfc)
- Gateway (ContactGateway.cfc)
- index.cfm - Deals with the business logic
- display/form.cfm - Produces the form for both add and edit behaviour
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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: 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...
|
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: 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
|
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...
| |