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

How do I prevent this action?

On a multi-textbox form, linked to an external js, I use onBlur to call:

function chkNum(cellname) {
var str = document.getElementById(cellname).value.toString(1 0);
if (str < 28 || str > 36) {alert("Temperature entered is out of range.");
return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?

--
Ed Jay (remove M to respond by email)
Dec 21 '05 #1
14 2310
On 21/12/2005 22:40, Ed Jay wrote:
[...] I use onBlur to call:

^^^^^^
Use the change event and validate in response to the submit event, too.

The blur event should be used sparingly. Too many things can cause a
control to lose focus, so it's kinder to the user to only bug them if
they /changed/ a value and entered an invalid value.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Dec 22 '05 #2
Ed Jay said the following on 12/21/2005 5:40 PM:
On a multi-textbox form, linked to an external js, I use onBlur to call:

function chkNum(cellname) {
var str = document.getElementById(cellname).value.toString(1 0);
if (str < 28 || str > 36) {alert("Temperature entered is out of range.");
return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?


Set the value of the textbox within range.

<input type="text" value="28" .....>

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 22 '05 #3
Lee <RE**************@cox.net> wrote:
Ed Jay said:

On a multi-textbox form, linked to an external js, I use onBlur to call:

function chkNum(cellname) {
var str = document.getElementById(cellname).value.toString(1 0);
if (str < 28 || str > 36) {alert("Temperature entered is out of range.");
return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?


Don't audit onBlur. Use onChange, instead.


Lee, Mike, Randy...Thanks very much.

--
Ed Jay (remove M to respond by email)
Dec 22 '05 #4
Ed Jay wrote:
I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?


If you meant that you didn't want the error when the field is empty,
then of course:

var tmp = obj.value;

if (tmp != "" && (tmp <28 || tmp > 36))
alert("out of range");

I'm not sure why you're using toString() when you have the values. ??

Kev

Dec 22 '05 #5
"Kevin Darling" <kd******@basit.com> wrote:
Ed Jay wrote:
I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?
If you meant that you didn't want the error when the field is empty,
then of course:

var tmp = obj.value;

if (tmp != "" && (tmp <28 || tmp > 36))
alert("out of range");


Thanks.
I'm not sure why you're using toString() when you have the values. ??

It didn't work otherwise.

--
Ed Jay (remove M to respond by email)
Dec 22 '05 #6
Ed Jay wrote:
On a multi-textbox form, linked to an external js, I use onBlur to call:

function chkNum(cellname) {
Seems you've got plenty of answers above, guess I'm a little slow but
here you go anyway...

I guess you call this something like:

<input type="text" name="textbox" onblur="chkNum('textbox');" ... >
A much better idea is to use 'this', so you call the function:

<input type="text" name="textbox" onblur="chkNum(this);" ... >
And you function statement starts:

function chkNum(cell) {
As others have said, using onblur and an alert for validation is really
annoying.

var str = document.getElementById(cellname).value.toString(1 0);
The value of an input element is always passed as a string, toString
serves no useful purpose.

var str = cell.value;

if (str < 28 || str > 36)
Even though values are passed as strings, they are type-converted to
numbers when evaluate this way so this line will work as it does now.

However, you should ensure that the values entered into the text input
were numbers in the first place. If you want to validate that they were
integers, there are plenty of examples in the archives, or use something
from here:

<URL:http://www.merlyn.demon.co.uk/js-valid.htm#Val>

... {alert("Temperature entered is out of range.");
If there is a set range, then better to let the user know:
{ alert("Temperature must be between 28 and 36 inclusive");
return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?


Allow no input at all, replace:

if (str < 28 || str > 36)
With:

if (str && (str < 28 || str > 36))


--
Rob
Dec 22 '05 #7
RobG <rg***@iinet.net.au> wrote:
Ed Jay wrote:
On a multi-textbox form, linked to an external js, I use onBlur to call:

function chkNum(cellname) {
Seems you've got plenty of answers above, guess I'm a little slow but
here you go anyway...

I guess you call this something like:

<input type="text" name="textbox" onblur="chkNum('textbox');" ... >


Yes.
A much better idea is to use 'this', so you call the function:

<input type="text" name="textbox" onblur="chkNum(this);" ... >

And you function statement starts:

function chkNum(cell) {
Works fine, thanks.
As others have said, using onblur and an alert for validation is really
annoying.
Understood, but I don't want to wait until a submit to notify the user. No
offense intended to doctors, but my user is a medical doctor and if I wait
to validate until a submit, the guy will stare at the screen for days
trying to figure out which cell has the invalid entry. ;-)
var str = document.getElementById(cellname).value.toString(1 0);
The value of an input element is always passed as a string, toString
serves no useful purpose.

var str = cell.value;
if (str < 28 || str > 36)


Even though values are passed as strings, they are type-converted to
numbers when evaluate this way so this line will work as it does now.

However, you should ensure that the values entered into the text input
were numbers in the first place. If you want to validate that they were
integers, there are plenty of examples in the archives, or use something
from here:

<URL:http://www.merlyn.demon.co.uk/js-valid.htm#Val>


Yes, I'm already filtering input to assure only digits and a single
decimal.
... {alert("Temperature entered is out of range.");


If there is a set range, then better to let the user know:
{ alert("Temperature must be between 28 and 36 inclusive");

To enter the data, the User is looking at a photo with the temperature
shown. The error _should be_ obvious.
return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?


Allow no input at all, replace:

if (str < 28 || str > 36)
With:

if (str && (str < 28 || str > 36))


The problem with this approach is that using onChange as my event, with no
data entered, there is no change when I go to the next cell. At least when
I click on an empty cell and then move to the next cell, there's no alert.

The other issue with using onChange is that the user need only click the
cell with the invalid entry and then click to the next cell. There's no
change, so there's no function call. I guess the final validity test will
have to catch the error.

Is there a method for returning the cursor to the errant entry when the
alert is triggered?

--
Ed Jay (remove M to respond by email)
Dec 22 '05 #8
Ed Jay wrote:
RobG <rg***@iinet.net.au> wrote:

Ed Jay wrote:
[...]
As others have said, using onblur and an alert for validation is really
annoying.

Understood, but I don't want to wait until a submit to notify the user. No
offense intended to doctors, but my user is a medical doctor and if I wait
to validate until a submit, the guy will stare at the screen for days
trying to figure out which cell has the invalid entry. ;-)


OK, they're your users... but you could also consider having an area set
aside for messages to show alerts as text in the page.
[...]
... {alert("Temperature entered is out of range.");


If there is a set range, then better to let the user know:

{ alert("Temperature must be between 28 and 36 inclusive");

To enter the data, the User is looking at a photo with the temperature
shown. The error _should be_ obvious.


But it is always good to let them know why it's out of range. Error
messages are like e-mail, very impersonal and it's easy to offend people
so they get a bad impression of your program. On the other hand, smarmy
messages make me puke - over to you :-)

return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?
Allow no input at all, replace:

if (str < 28 || str > 36)
With:

if (str && (str < 28 || str > 36))

The problem with this approach is that using onChange as my event, with no
data entered, there is no change when I go to the next cell. At least when
I click on an empty cell and then move to the next cell, there's no alert.


Designing a good user interface is really tough. onchange will only
fire if the input changes, so I don't think it's the right event here.

My above suggestion was intended to be used onblur - but isn't no entry
the same as an out-of-range value? So I don't think it's a valid solution.

An alternative is to validate the entire form each time, stopping at the
first invalid entry. But this won't work if they enter a value into the
second text box first, they'll get an error that the first box is out of
range.

The other issue with using onChange is that the user need only click the
cell with the invalid entry and then click to the next cell. There's no
change, so there's no function call. I guess the final validity test will
have to catch the error.
Exactly.

I think the best method is to use in-page messages for each validated
field. That way the user can see what's invalid and what isn't, then
it's up to them to fix it. Validate again on submit.

Nearly any method has sneaky work-arounds that a user can adopt to avoid
your alerts (as you've noted) or inconsistencies with how the form is
used. Coding to prevent them all makes a rigid interface that is very
frustrating to use. If you users are doctors, hopefully they have the
intelligence to understand that if they make an error they will be
warned to fix it and that ultimately it's up to them to do it.


Is there a method for returning the cursor to the errant entry when the
alert is triggered?


You can call the focus method after displaying the alert:

...
alert("Temperature entered is out of range.");
if (cell.focus) cell.focus();
}

If used in conjunction with onblur, this will trap the user in the field
until a valid number is entered (hence it would be nice to let them know
what the valid range is).
--
Rob
Dec 22 '05 #9
RobG <rg***@iinet.net.au> wrote:
Ed Jay wrote:
RobG <rg***@iinet.net.au> wrote:

Ed Jay wrote:
[...]
As others have said, using onblur and an alert for validation is really
annoying.

Understood, but I don't want to wait until a submit to notify the user. No
offense intended to doctors, but my user is a medical doctor and if I wait
to validate until a submit, the guy will stare at the screen for days
trying to figure out which cell has the invalid entry. ;-)


OK, they're your users... but you could also consider having an area set
aside for messages to show alerts as text in the page.


Excellent idea.

[...]
... {alert("Temperature entered is out of range.");

If there is a set range, then better to let the user know:
{ alert("Temperature must be between 28 and 36 inclusive");
To enter the data, the User is looking at a photo with the temperature
shown. The error _should be_ obvious.


But it is always good to let them know why it's out of range. Error
messages are like e-mail, very impersonal and it's easy to offend people
so they get a bad impression of your program. On the other hand, smarmy
messages make me puke - over to you :-)


lol. I agree with you. alert("Look at the photo, dummy!") :-)
return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?

Allow no input at all, replace:

if (str < 28 || str > 36)
With:

if (str && (str < 28 || str > 36))

The problem with this approach is that using onChange as my event, with no
data entered, there is no change when I go to the next cell. At least when
I click on an empty cell and then move to the next cell, there's no alert.


Designing a good user interface is really tough. onchange will only
fire if the input changes, so I don't think it's the right event here.

My above suggestion was intended to be used onblur - but isn't no entry
the same as an out-of-range value? So I don't think it's a valid solution.

An alternative is to validate the entire form each time, stopping at the
first invalid entry. But this won't work if they enter a value into the
second text box first, they'll get an error that the first box is out of
range.

The other issue with using onChange is that the user need only click the
cell with the invalid entry and then click to the next cell. There's no
change, so there's no function call. I guess the final validity test will
have to catch the error.


Exactly.

I think the best method is to use in-page messages for each validated
field. That way the user can see what's invalid and what isn't, then
it's up to them to fix it. Validate again on submit.

Nearly any method has sneaky work-arounds that a user can adopt to avoid
your alerts (as you've noted) or inconsistencies with how the form is
used. Coding to prevent them all makes a rigid interface that is very
frustrating to use. If you users are doctors, hopefully they have the
intelligence to understand that if they make an error they will be
warned to fix it and that ultimately it's up to them to do it.


Is there a method for returning the cursor to the errant entry when the
alert is triggered?


You can call the focus method after displaying the alert:

...
alert("Temperature entered is out of range.");
if (cell.focus) cell.focus();
}

If used in conjunction with onblur, this will trap the user in the field
until a valid number is entered (hence it would be nice to let them know
what the valid range is).


Good suggestions, all. Thanks much.

--
Ed Jay (remove M to respond by email)
Dec 22 '05 #10
RobG <rg***@iinet.net.au> wrote:
Ed Jay wrote:
RobG <rg***@iinet.net.au> wrote:

Ed Jay wrote:
[...]
As others have said, using onblur and an alert for validation is really
annoying.


Understood, but I don't want to wait until a submit to notify the user. No
offense intended to doctors, but my user is a medical doctor and if I wait
to validate until a submit, the guy will stare at the screen for days
trying to figure out which cell has the invalid entry. ;-)


OK, they're your users... but you could also consider having an area set
aside for messages to show alerts as text in the page.
[...]
... {alert("Temperature entered is out of range.");

If there is a set range, then better to let the user know:
{ alert("Temperature must be between 28 and 36 inclusive");

To enter the data, the User is looking at a photo with the temperature
shown. The error _should be_ obvious.


But it is always good to let them know why it's out of range. Error
messages are like e-mail, very impersonal and it's easy to offend people
so they get a bad impression of your program. On the other hand, smarmy
messages make me puke - over to you :-)

return;}
}

I enter data into the first textbox and move the cursor to the second
textbox. The function is properly called. Since textbox2 is empty, when I
move the cursor back to textbox1, I again (appropriately) get the alert.
How can I prevent this?

Allow no input at all, replace:

if (str < 28 || str > 36)
With:

if (str && (str < 28 || str > 36))

The problem with this approach is that using onChange as my event, with no
data entered, there is no change when I go to the next cell. At least when
I click on an empty cell and then move to the next cell, there's no alert.


Designing a good user interface is really tough. onchange will only
fire if the input changes, so I don't think it's the right event here.

My above suggestion was intended to be used onblur - but isn't no entry
the same as an out-of-range value? So I don't think it's a valid solution.

An alternative is to validate the entire form each time, stopping at the
first invalid entry. But this won't work if they enter a value into the
second text box first, they'll get an error that the first box is out of
range.

The other issue with using onChange is that the user need only click the
cell with the invalid entry and then click to the next cell. There's no
change, so there's no function call. I guess the final validity test will
have to catch the error.


Exactly.

I think the best method is to use in-page messages for each validated
field. That way the user can see what's invalid and what isn't, then
it's up to them to fix it. Validate again on submit.

Nearly any method has sneaky work-arounds that a user can adopt to avoid
your alerts (as you've noted) or inconsistencies with how the form is
used. Coding to prevent them all makes a rigid interface that is very
frustrating to use. If you users are doctors, hopefully they have the
intelligence to understand that if they make an error they will be
warned to fix it and that ultimately it's up to them to do it.


Is there a method for returning the cursor to the errant entry when the
alert is triggered?


You can call the focus method after displaying the alert:

...
alert("Temperature entered is out of range.");
if (cell.focus) cell.focus();
}

If used in conjunction with onblur, this will trap the user in the field
until a valid number is entered (hence it would be nice to let them know
what the valid range is).


A bit of a problem with this scheme. Best illustration...goto
<http://www.edbj.aes-intl.com/jstest5.html>. Click on Box1, but enter no
data. Then, click Box2. If you have good eyes, you can observe the cursor
alternating between the two boxes while the alert remains on screen.

The code:

function chkNum(cell) {
var str = cell.value;
if (str.length == 0) {alert("Missing data");if (cell.focus)
cell.focus();return;}
if (str && (str < 28 || str > 36)) {alert("Temperature entered is out of
range.");if (cell.focus) cell.focus();return;}
if (str.length != 4) {alert("Enter temperature to one decimal place.");if
(cell.focus) cell.focus();
return;}
}

<form name="form1" action="">
Box1: <input type="text" name="box1" size=4 onkeypress="return
onlyDigits(event,'decOK')" onBlur="chkNum(this)">
<br>
Box2: <input type="text" name=box2 size=4 onkeypress="return
onlyDigits(event,'decOK')" onBlur="chkNum(this)">
<br><br>
<input type="submit" value="Submit">
</form>

Thoughts?

--
Ed Jay (remove M to respond by email)
Dec 22 '05 #11
Ed Jay wrote:
[...]
A bit of a problem with this scheme. Best illustration...goto
<http://www.edbj.aes-intl.com/jstest5.html>. Click on Box1, but enter no
data. Then, click Box2. If you have good eyes, you can observe the cursor
alternating between the two boxes while the alert remains on screen.


Depends on which browser you are using I guess. Seems to me you are
back at the beginning - firing the validation onblur does not give a
satisfactory result.

A couple of tips: trim quotes to only what is relevant and manually wrap
code at about 70 characters (75 max) to allow for a couple of re-posts
without wrapping.

Indent code using 2 or 4 spaces, non-indented code is much harder to
read, especially if random auto-wrapping has also occurred.

I would do something more like the following (with onsubmit validation too):

<head>
<title>...</title>

<style type="text/css">
.erMsg {
color: #f00;
background-color: #fff;
font-weight: bold;
white-space: nowrap;
}
</style>

</head>
<body>
<script type="text/javascript">

function chkNum(cell)
{
var str = cell.value;
var erMsg = '';
var erEl;

// Set min and max range values
var minVal = 28.0;
var maxVal = 36.0;
var erTxt = ' from ' + minVal + ' to ' + maxVal + '.';

if (!str) {
erMsg = 'Enter a value' + erTxt;
} else if ( !validNum(str) ){
erMsg = str + ' isn\'t valid, enter a value' + erTxt;
} else if ( str < minVal || str > maxVal){
erMsg = 'Out of range. Value must be' + erTxt;
}

if ( document.getElementById
&& '' != cell.name
&& (erEl = document.getElementById(cell.name + '_er'))){
erEl.innerHTML = erMsg;
} else {
alert(erMsg);
}
}

function validNum(n){
return /^\d\d(.\d)?$/.test(n);
}

</script>

<form name="form1" action="">
Box1: <input type="text" name="box1" size="4"
onBlur="chkNum(this)"><span id="box1_er"
class="erMsg"></span><br>
Box2: <input type="text" name="box2" size="4"
onBlur="chkNum(this)"><span id="box2_er"
class="erMsg"></span><br>
<input type="submit" value="Submit">
</form>

</body>

[...]

--
Rob
Dec 22 '05 #12
RobG <rg***@iinet.net.au> wrote:
Ed Jay wrote:
[...]
A bit of a problem with this scheme. Best illustration...goto
<http://www.edbj.aes-intl.com/jstest5.html>. Click on Box1, but enter no
data. Then, click Box2...
..Seems to me you are
back at the beginning - firing the validation onblur does not give a
satisfactory result.


I think it's appropriate to go back to using onChange instead of onBlur,
then do a js validate onSubmit and again in my server-side script.
A couple of tips: trim quotes to only what is relevant and manually wrap
code at about 70 characters (75 max) to allow for a couple of re-posts
without wrapping.
I'm wrapping at 74 chrs.
Indent code using 2 or 4 spaces, non-indented code is much harder to
read, especially if random auto-wrapping has also occurred.
Sorry.
I would do something more like the following (with onsubmit validation too):

<head>
<title>...</title>

<style type="text/css">
.erMsg {
color: #f00;
background-color: #fff;
font-weight: bold;
white-space: nowrap;
}
</style>

</head>
<body>
<script type="text/javascript">

function chkNum(cell)
{
var str = cell.value;
var erMsg = '';
var erEl;

// Set min and max range values
var minVal = 28.0;
var maxVal = 36.0;
var erTxt = ' from ' + minVal + ' to ' + maxVal + '.';

if (!str) {
erMsg = 'Enter a value' + erTxt;
} else if ( !validNum(str) ){
erMsg = str + ' isn\'t valid, enter a value' + erTxt;
} else if ( str < minVal || str > maxVal){
erMsg = 'Out of range. Value must be' + erTxt;
}

if ( document.getElementById
&& '' != cell.name
&& (erEl = document.getElementById(cell.name + '_er'))){
erEl.innerHTML = erMsg;
} else {
alert(erMsg);
}
}

function validNum(n){
return /^\d\d(.\d)?$/.test(n);
}

</script>

<form name="form1" action="">
Box1: <input type="text" name="box1" size="4"
onBlur="chkNum(this)"><span id="box1_er"
class="erMsg"></span><br>
Box2: <input type="text" name="box2" size="4"
onBlur="chkNum(this)"><span id="box2_er"
class="erMsg"></span><br>
<input type="submit" value="Submit">
</form>

I've been playing around with both innerHTML and a hidden div to print and
erase error messages. Very similar to your scheme.

Thanks for all of your help.

--
Ed Jay (remove M to respond by email)
Dec 22 '05 #13
On 22/12/2005 01:22, Ed Jay wrote:
RobG <rg***@iinet.net.au> wrote:
[snip]
As others have said, using onblur and an alert for validation is really
annoying.


Understood, but I don't want to wait until a submit to notify the user.


Which is why the change event is used as well. It will validate values
as they are entered, and the validation triggered by submission will
catch missed fields, and those that may be still invalid but unchanged.

Trapping a user with the blur event is a usability failure. If the user
tabs through the fields (or clicks from one to the other), they
shouldn't be told every single time that need to enter a valid value.

[snip]
if (str < 28 || str > 36)


Even though values are passed as strings, they are type-converted to
numbers when evaluate this way so this line will work as it does now.

However, you should ensure that the values entered into the text input
were numbers in the first place.


In general, yes, but it's not really necessary here. If they values
weren't numeric, they would be type-converted to NaN which, in a
RelationalExpression, evaluates to undefined and in turn to boolean false.

[snip]
The problem with this approach is that using onChange as my event, with no
data entered, there is no change when I go to the next cell. At least when
I click on an empty cell and then move to the next cell, there's no alert.
By design and from the user's point of view, a good thing.
The other issue with using onChange is that the user need only click the
cell with the invalid entry and then click to the next cell. There's no
change, so there's no function call. I guess the final validity test will
have to catch the error.
If that's what the user chooses to do, then yes. But, there's every
possibility that the user skipped the field to do something else first,
and has every intention to go back and change it (which is why they
should be allowed to do that unhindered).
Is there a method for returning the cursor to the errant entry when the
alert is triggered?


Yes, you can call the focus method of the INPUT element. However, if you
do that then you /must not/ use the blur event. Doing so may lead to an
infinite loop of blur events and alerts.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Dec 22 '05 #14
Michael Winter <m.******@blueyonder.co.uk> wrote:
On 22/12/2005 01:22, Ed Jay wrote:
RobG <rg***@iinet.net.au> wrote:


[snip]
As others have said, using onblur and an alert for validation is really
annoying.


Understood, but I don't want to wait until a submit to notify the user.


Which is why the change event is used as well. It will validate values
as they are entered, and the validation triggered by submission will
catch missed fields, and those that may be still invalid but unchanged.

Trapping a user with the blur event is a usability failure. If the user
tabs through the fields (or clicks from one to the other), they
shouldn't be told every single time that need to enter a valid value.

[snip]
if (str < 28 || str > 36)

Even though values are passed as strings, they are type-converted to
numbers when evaluate this way so this line will work as it does now.

However, you should ensure that the values entered into the text input
were numbers in the first place.


In general, yes, but it's not really necessary here. If they values
weren't numeric, they would be type-converted to NaN which, in a
RelationalExpression, evaluates to undefined and in turn to boolean false.

[snip]
The problem with this approach is that using onChange as my event, with no
data entered, there is no change when I go to the next cell. At least when
I click on an empty cell and then move to the next cell, there's no alert.


By design and from the user's point of view, a good thing.
The other issue with using onChange is that the user need only click the
cell with the invalid entry and then click to the next cell. There's no
change, so there's no function call. I guess the final validity test will
have to catch the error.


If that's what the user chooses to do, then yes. But, there's every
possibility that the user skipped the field to do something else first,
and has every intention to go back and change it (which is why they
should be allowed to do that unhindered).
Is there a method for returning the cursor to the errant entry when the
alert is triggered?


Yes, you can call the focus method of the INPUT element. However, if you
do that then you /must not/ use the blur event. Doing so may lead to an
infinite loop of blur events and alerts.

Thanks, Mike. Your points are well made. After spending all night
contemplating the issue, they are also well taken.

--
Ed Jay (remove M to respond by email)
Dec 22 '05 #15

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

Similar topics

3
by: andy johnson | last post by:
Hi, I'm validating an html file with this script and have this error message from the validator: Line 101, character 22: <FORM NAME="DropDown"> ^ Error: required attribute ACTION not...
3
by: penny336 | last post by:
dear all, i am using vc++ 6.0 sp5 i have a class called Address,it allocated some memory space for streetname and city i first define it as Address add = new Address("Madrian","UK"); ......
10
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"> ...
24
by: Charles Law | last post by:
When I click a button I don't want the click event to fire. Is this possible? In fact, what I would really like is to be able to intercept the click event, perform some action, and then prevent...
16
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
3
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data...
4
by: since | last post by:
How do I in IE prevent the onclick action from being fired when I am done dragging? have tried "window.event.cancelBubble = true", for onmouseup , onmousedown, and onmousemove handlers. The onclick...
6
by: Stanimir Stamenkov | last post by:
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"...
2
by: Carlos | last post by:
Hi all, I need to know how to prevent to repeat the operations that happen when the submit button is clicked, when the page is refreshed. I noticed that if I refresh my page after the submit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
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
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
agi2029
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,...
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.