PDA

View Full Version : Skip its validation alert if that text box is hidden



MSK7
06-30-2009, 12:55 PM
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

clueful
07-02-2009, 12:08 AM
As usual it would have helped if you'd shown the existing code, but (assuming you're using the CSS display property):


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