Results 1 to 2 of 2

Thread: Skip its validation alert if that text box is hidden

  1. #1
    Join Date
    Feb 2009
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Skip its validation alert if that text box is hidden

    Hello all,

    I have a form in which there are two radio buttons .

    On selecting the first radio button1 , two textboxes are displayed ( textbox1 & textbox2 ).

    & On selecting the second radio button2 only One textbox is

    displayed (textbox1) & another one (textbox2) get hidden .

    what i am trying to do is that when radio button1 is selected

    & so two textboxes are displayed,

    then Onsubmit throw alert for two textboxes seperately , to

    Enter value in them if this text boxes are blank .

    But if radio button2 is selected then throw alert for Entering

    value for only one text box (textbox1) if its value is blank ,

    & Skip alert throw for the another one hidden textbox(textbox2) .


    please suggest me how i can achieve this using JS .

    Thanks & Regards
    Last edited by MSK7; 06-30-2009 at 01:19 PM.

  2. #2
    Join Date
    Jul 2008
    Posts
    128
    Thanks
    0
    Thanked 17 Times in 16 Posts

    Default

    As usual it would have helped if you'd shown the existing code, but (assuming you're using the CSS display property):

    Code:
    if( element.value == "" && element.style.display != "none" )
     alert( ... );

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •