Regarding OnBlur Event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • btreddy
    New Member
    • Oct 2008
    • 83

    #1

    Regarding OnBlur Event

    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 CausesValidatio n="false" for the close button but it didn work for me..

    Kindly suggest mehow can i do this .

    Thanks in advance.
    BTR>
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    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!

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by kenobewan
      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!
      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:
      Code:
      //indicates whether or not to perform validation.
      var validateTextBox = true;
      
      //indicates that the validation should be surpressed for the current event
      function SurpressValidation()
      {    validateTextBox  =  false;}
      
      function MyOnBlurHandler()
      {    if(validateTextBox)
           {
                 //do validation....
      
            }
           else
           {  validateTextBox = false;
              return true;
            }
      }
      Now have your Close button call the SurpressValidat ion method during the JavaScript onclick event (onclientclick) .


      Have you considered looking into using the ASP.NET Validator Controls?

      Comment

      • btreddy
        New Member
        • Oct 2008
        • 83

        #4
        Hii Thank you Very much for your reply.

        Comment

        Working...