473,378 Members | 1,539 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,378 software developers and data experts.

Regarding OnBlur Event

83
Hii,
In one of my form i've textboxes and a button,Close, which closes the form .In the OnBlur event of the text boxes im calling the javascript function which alerts the user if the textbox is empty...if the textbox is empty and if i clicked on the close button its showing the alert message only..instead of closing the form (ofcourse this is what the default behaviour of OnBlur event).But I wanna to close the form whenevenr the user click the close button irrespective of the textboxes are empty or not.

i tried the CausesValidation="false" for the close button but it didn work for me..

Kindly suggest mehow can i do this .

Thanks in advance.
BTR>
Mar 4 '09 #1
3 2810
kenobewan
4,871 Expert 4TB
Wouldn't you need to use a different event in that case? E.g. onClose event. You may be able to fudge by closong the form, form.close(), in the onBlur. Suggest try and see what happens... mehow!
Mar 4 '09 #2
Frinavale
9,735 Expert Mod 8TB
@kenobewan
There's a form.close() in ASP.NET???

Is the OnBlur event happening when you are closing the window?

I'd suggest making a JavaScript function that set's a variable that indicates when the check should happen.

So you'd add a function that would set this variable to "true" when the validation shouldn't be executed, otherwise validate....

So in your method that handles the OnBlur event for your TextBox, you'd have:
Expand|Select|Wrap|Line Numbers
  1. //indicates whether or not to perform validation.
  2. var validateTextBox = true;
  3.  
  4. //indicates that the validation should be surpressed for the current event
  5. function SurpressValidation()
  6. {    validateTextBox  =  false;}
  7.  
  8. function MyOnBlurHandler()
  9. {    if(validateTextBox)
  10.      {
  11.            //do validation....
  12.  
  13.       }
  14.      else
  15.      {  validateTextBox = false;
  16.         return true;
  17.       }
  18. }
Now have your Close button call the SurpressValidation method during the JavaScript onclick event (onclientclick).


Have you considered looking into using the ASP.NET Validator Controls?
Mar 5 '09 #3
btreddy
83
Hii Thank you Very much for your reply.
Mar 6 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Barry Svee | last post by:
I'm struggling with the JavaScript blur event. I have an activex control that I need to interact with when a window loses focus, namely to instruct it to give up control of a barcode scanner so...
2
by: D. Alvarado | last post by:
Hi, I'm having some trouble with the "onBlur" event in the BODY tag. Ideally, what I want to happen is that when someone leaves window A, window A executes a command. I had put <body...
4
by: Peloux | last post by:
Hi, I have written some htc in order to validate data in a form. most of htc are attached on 'onblur' event. Now, we would like to use the Enter Key to sublit form, so we use the following...
2
by: andyalean | last post by:
Hello javascript coders :( ,I am trying to add an onblur event to my code. This is where I dynamically create a textfield.I want to assign it an onblur event handler like so.How do I add a event...
5
by: Dave Hammond | last post by:
Hi All, I have a web form which performs certain actions upon moving focus away from a field. However, if the user clicks the top corner 'X' icon to close the window, the onBlur event still...
2
by: Heiko Vainsalu | last post by:
Hi Hope somebody knows how to solve this one. *The Situation* A traditional situation where HTML form inputs are checked... (if simplified then it would look something like this) <form...
1
by: neil S via DotNetMonster.com | last post by:
I have a custom control with a textbox and dropdown list. The dropdown list is hidden and acts as a data source for the textbox. When the user enters text in the textbox, an onKeyup event is...
10
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...
2
by: wolverine | last post by:
Hi All, In Mozilla Firefox, to onblur and onfocus event of each and every html element, the browser itself will attach a native event handler. I mean if you type,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.