I'm writing a small ASP program which prompts the user for data. I
would like to interactively validate the data as they are entering it,
rather than waiting until they submit the form. So, I am doing
something like this (this is a very simple example):
<head>
<script language=javasc ript>
function validatefield1( )
var i;
i = document.myForm .field1.value
if ( i < 10 or i > 20 ) {
alert("please enter a # between 10 and 20!");
document.getEle mentByID('field 1').focus();
return false;
}
return true;
}
function validatefield2( )
var i;
i = document.myForm .field2.value
if ( i < 20 or i > 30 ) {
alert("please enter a # between 20 and 30!");
document.getEle mentByID('field 2').focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form name=myForm id=myForm method=post action='/nextpage.asp'>
Field1: <input type=text size=2 id=field1 name=field1
onblur='validat efield1();'>
Field2: <input type=text size=2 id=field1 name=field1
onblur='validat efield2();'>
</form>
</body>
Here is the problem:
By default the first field has focus. If I press tab to bypass it
without entering anything, focus shifts to field2 immediately. The
onblur event fires, which checks the value in field1, sees it is
invalid, so prints an error message and resets the focus to field2.
Naturally, this causes field2 to lose focus. This causes field2's blur
event to kick of, which causes an error (since the field is blank),
printing an error, setting focus back to field2.
The effect is an endless loop of error messages.
I've tried other combinations of events, such as ondeactivate, but they
all result in the same behavior.
Why does the focus shift from field1 to field2 prior to the onblur
event completing?
Can someone explain the proper sequence of event processing on ASP
forms? When I press tab in field1, why does focus shift to field2 prior
to the onblur event for field1 completing? I can't seem to find this
documented anywhere in the msdn documentation to explain how events are
sequenced on IIS forms.
Alternatively, can someone suggest which event I would use to
accomplish what I'm trying to do? I'd prefer to interactively validate
data, rather than waiting until the form is submitted which I think is
messy and unprofessional, compared to the VB apps I've written.
Thanks
Vin 2 1582
On 23 Feb 2006 16:47:04 -0800, "Vinny" <te*****@yahoo. com> wrote: I'm writing a small ASP program which prompts the user for data. I would like to interactively validate the data as they are entering it, rather than waiting until they submit the form.
Can't in ASP. Client side code would be needed, until the form is
submitted the server can't respond.
Jeff
Vinny wrote: I'm writing a small ASP program which prompts the user for data. I would like to interactively validate the data as they are entering it, rather than waiting until they submit the form. So, I am doing something like this (this is a very simple example):
<head> <script language=javasc ript>
function validatefield1( ) var i; i = document.myForm .field1.value if ( i < 10 or i > 20 ) { alert("please enter a # between 10 and 20!"); document.getEle mentByID('field 1').focus(); return false; } return true; }
function validatefield2( ) var i; i = document.myForm .field2.value if ( i < 20 or i > 30 ) { alert("please enter a # between 20 and 30!"); document.getEle mentByID('field 2').focus(); return false; } return true; } </script> </head> <body> <form name=myForm id=myForm method=post action='/nextpage.asp'> Field1: <input type=text size=2 id=field1 name=field1 onblur='validat efield1();'> Field2: <input type=text size=2 id=field1 name=field1 onblur='validat efield2();'> </form> </body>
Here is the problem:
By default the first field has focus. If I press tab to bypass it without entering anything, focus shifts to field2 immediately. The onblur event fires, which checks the value in field1, sees it is invalid, so prints an error message and resets the focus to field2.
Naturally, this causes field2 to lose focus. This causes field2's blur event to kick of, which causes an error (since the field is blank), printing an error, setting focus back to field2.
The effect is an endless loop of error messages.
I've tried other combinations of events, such as ondeactivate, but they all result in the same behavior.
Why does the focus shift from field1 to field2 prior to the onblur event completing?
Can someone explain the proper sequence of event processing on ASP forms?
ASP is irrelevant in your context, and there is no such thing as an
"ASP" form. There is an HTML form, which you can use server-side ASP
to process, or you can use client-side javascript (or a mixture of
both).
In your case, you would be better off asking this question in a
client-side code newsgroup.
/P. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Hosh |
last post by:
I have a form on a webpage and want to use JavaScript validation for the
form fields.
I have searched the web for form validation scripts and have come up with
scripts that only validate individual fields, such as an "Email Validation
Script" or a "Phone Validation Script".
Is it ok to put all these scripts on page as they are or should they be
joined in some way together to be one script?
I'm a total JavaScript newbie and am completely...
|
by: qsweetbee |
last post by:
I have a form(fAddUsers) in my database. It is continue form for data
entry. Some fields are required fields. Some are optional fields.
There is 1 particular filed(TokenExpirationDate)on the form which is
depended on the other field(TokenID)whether it is blank or not. If
the "TokenID" field is blank, the "TokenExpirationDate" field can be
blank also. But if the "TokenID" field is not blank or null, the
"TokenExpirationDate" field must be...
|
by: Earthling |
last post by:
Any help would be appreciated to solve the following simple problem that
I will describe.
***
There is a form called "red chocolate form".
The form has a particular subform field that has a checkmark box that is
selectable as on or off (on if there is a checkmark inside it).
The table that contains the data for the form is known as "red chocolate
|
by: Jack Addington |
last post by:
I've got a fairly simple application implementation that over time is going
to get a lot bigger. I'm really trying to implement it in a way that will
facilitate the growth. I am first writing a WinForms interface and then
need to port that to a web app. I am kinda stuck on a design issue and need
some suggestions / direction.
Basically I have a business layer that I want to use to process any
dataentry logic (row focus changes, data...
|
by: h7qvnk7q001 |
last post by:
I'm trying to implement a simple server-side form validation (No
Javascript). If the user submits a form with errors, I want to
redisplay the same form with the errors highlighted. Once the form is
correct I need to submit to another page that uses the form data.
I first tried making the form submit action= field point to the same
file. When the form was correct, I tried loading the next page by using
<META http-equiv refresh>. But...
| |
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: aljamala |
last post by:
Hi,
I keep getting this warning on a page, but I do not know what the
problem is...does anyone have an idea about what could be wrong?
line 88 column 7 - Warning: missing </formbefore <td>
it highlights this line: <form name="frmCurrency" action=""
method="post">
Page source....
|
by: rynato |
last post by:
I have a form which the user fills out to enter some data.
If there already exists an uncompleted session - say, the user started
entering some data but had to stop to do something else - the user has
the option of selecting that session from a drop-down menu (think
<form><select><option>....</option></select></form>). The method for
that particular form is set to 'GET' and the action is
$_SERVER. The <selecttag has a bit of javascript...
|
by: smk17 |
last post by:
I've spent the last few minutes searching for this question and I
found an answer, but it wasn't quite what the client wanted.
I have a simple online form where the user needs to fill out five
fields out of nine. The other four are already there and filled out
for the user. When they hit submit, all data is sent to us.
But, if they desire (for whatever reason) the user can possibly delete
what is already there and fill in something...
|
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: 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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |