473,569 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onblur call issue

Hi all,

Can any one advice what can be a work around here?
When i run the code below, its showing the alert msg twice onfocus out
of tf1

Thanks in advance,
Maheshkumar

<html>
<script type="text/javascript">

function setFocus(ref) {
globalTakeFocus =ref;
setTimeout("glo balTakeFocus.fo cus();globalTak eFocus.select() ",100);
}

function checkfun()
{
if(document.get ElementById("tf 1").value==" ")
{
//document.getEle mentById("tf1") .focus();
alert("The field is empty");
setFocus(docume nt.getElementBy Id("tf1"));
return;
}

if(document.get ElementById("tf 2").value==" ")
{
//document.getEle mentById("tf2") .focus();
alert("The field is empty");
setFocus(docume nt.getElementBy Id("tf2"));
return;
}
}

</script>
<body>
<table>
<form>
<tr<td>
TF1: <input id="tf1" type="text" value="" onblur="checkfu n();"/></td>
</tr>
<tr><td>
TF2: <input id="tf2" type="text" value="tf2" onblur="checkfu n()"/></
td>
</tr>
</form>
</table>
</body>
</html>

May 2 '07 #1
1 1860

Mahesh wrote:
Hi all,

Can any one advice what can be a work around here?
When i run the code below, its showing the alert msg twice onfocus out
of tf1
Sequence of the events:
1.tf1 lost focus.
2.tf2 got focus.
3.alert that was caused by tf1 onblur event is shown up (tf2 lost
focus).
4.alert that was caused by tf2 onblur event is shown up.
5.tf1 got focus.

You can avoid it in this way:

function checkfun(sender )
{
if(sender.value =="")
{
alert("The field is empty");
setFocus(sender );
}
}

TF1: <input id="tf1" type="text" value="" onblur="checkfu n(this)"/>
TF2: <input id="tf2" type="text" value="tf2" onblur="checkfu n(this)"/>

Regards

May 3 '07 #2

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

Similar topics

1
1619
by: eric.goforth | last post by:
Hello, I'm rendering a page with xml/xsl, for one control, I've set up a an xsl template something like: <xsl:template name="MyText"> <xsl:param name="sName"></xsl:param> <xsl:param name="sAction"></xsl:param> <INPUT TYPE="text" SIZE="7" MAXLENGTH="15" NAME="{$sName}" VALUE="Test" onblur="{$sAction}"></INPUT>
1
1925
by: clemtig | last post by:
Say I have a form with two input textfields. Each has an onFocus and onBlur. onFocus will unhide image #1. onBlur will hide image #1, show image #2 and validate the textfield. But the problem is that I get errors when going from one field to another with this combination. I've got it down to the point where I know that going from input...
1
2713
by: jb5531 | last post by:
Hello everyone! I am trying to implement some code for my website using JavaScript and DOM. The issue I'm having is that I want to change the size of the textarea on blur. This text area changes from an input box to a textarea once the value length reaches a certain number, passed to the function call. I cannot seem to reference this...
10
2442
by: John Kotuby | last post by:
Hello all... I am working on an ASP.NET 2.0 application with VS2005 and VB. I have chosen to use popup windows in some cases because it makes the user experience better (according to all the users I have polled who will be using this app). In an attempt to keep the popup from disappearing behind the calling window, I am adding the...
3
2264
by: alindtiwari | last post by:
hi everyone, i just want to share my experience....,that never use alert when u are calling 2 functions in the same tag using onkeyup or onblur events,........becoz wht ever function u r going to call in onkeyup,,,if there is any alert msg is there then...first the onblur function is called due to alert the focus is coming out of...
3
1331
by: empiresolutions | last post by:
i am using the following AJAX request method. Most of you probably use this script allready as it seems to be everywhere online. I use it often with out issue... until now. What I'm finding is that if the click used to initiate the onblur() used like <input type="text" id="qty" name="qty" value=""...
4
6915
by: rubenhan | last post by:
Hey, guys. My basic idea is this. When I write "1" in the pre-existing text field and onblur, I want to add a new field with a set of attributes, which turned out to be the same as the pre existing text field. (I don't want to use clonenode because of the compatibility issue) So I want that new text field to behave like the old text field....
0
7700
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, 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...
0
7924
Oralloy
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. ...
1
7676
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...
0
7974
tracyyun
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...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
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
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
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...

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.