NaniG Posted April 17, 2012 Share Posted April 17, 2012 Hi all, Here is the my code. <form name='formx'> <select id="sel" onchange="ShowHide(this,'other');"> <option value="">- select -</option> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 3</option> <option value="option4">Option 4</option> <option value="other">Other</option> </select> <label id="other" style="display:none;"> <input type="text" name="example" /> </label> </form> <script type="text/javascript" language="javascript"> function ShowHide(obj, id1) { txt1 = obj.options[obj.selectedIndex].value; document.getElementById(id1).style.display = 'none'; if ( txt1.match(id1) ) { document.getElementById(id1).style.display = 'block'; } } </script> when i selected "other", it will displaying the text box. Now, how can i validate these textbox ? It should be non-empty field. Thanks in Adv. Quote Link to comment https://forums.phpfreaks.com/topic/261132-javascript-dropdown-box-selcted-value-validation/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.