|
-
Sep 21st, 2001, 09:02 AM
#1
Thread Starter
Hyperactive Member
Onfocus code problem
Hi everyone!
I have a textbox called 'atm' (form is called 'AddCustForm') with two event handlers: onFocus and onBlur. Here is the code for both events.
Code:
onBlur="LookForBlank(this);"
function LookForBlank(sAtmNumb){
if (sAtmNumb.value=='' || sAtmNumb.value=='undefined'){
alert('The ATM # is missing. Please enter a ATM Number.');
AddCustForm.atm.focus();}
else{
document.location.href="addatmcust.asp?ATMNUMB=" + sAtmNumb.value;
}
}
onFocus="if (AddCustForm.atm.value != '' || AddCustForm.atm.value != 'undefined'){AddCustForm.customer.focus();}
The onBlur event works fine, but it is somehow conflicting with the onFocus event. This is how I want the onFocus event to work: If the atm field is NOT empty or NOT equal to 'undefined' then move the focus to the next field. I hope I haven't confused anyone.
Any input will be greatly appreciated. Thanks in advance.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Sep 24th, 2001, 12:43 PM
#2
Frenzied Member
I haven't played with an answer for this. There are several things that concern me, that could be potential problems.
For example, if there is a number, but it is wrong, I can never go back and change it. If I give the input focus, it will change focus.
But I do see a logic problem.
Since and empty string is not equal to 'undefined' the condition in the onFocus event will always be true. Which means that anytime you focus on this cell, it will try to change focus. Which may call the onBlur event.
You probably want to use one of the following clauses instead.
Code:
if !(AddCustForm.atm.value == '' || AddCustForm.atm.value == 'undefined')
if (AddCustForm.atm.value != '' && AddCustForm.atm.value != 'undefined')
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Sep 24th, 2001, 12:46 PM
#3
Thread Starter
Hyperactive Member
Thanks for your help.
I wanted to say thanks for your help. I am working with it now, so I am not sure if it will work or not. If I still have problems, I will reopen this thread.
Again, Thank you.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|