i want to validate a list box onthe onblur event and if no value is selected , display a message on the left using <span> and innerHTML
here's what i have written
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <script type="text/javascript">
- function validateCB()
- {
- if(document.rec.loc.options.selectedIndex = = 0)
- {
- alert(" hi");
- return false;
- }
- else
- return true;
- }
- function validatePID(inputfield, helptext)
- {
- if(inputfield.value.length !=9)
- ` {
- if(helptext != null)
- helptext.innerHTML = "please enter excatly 9 digits";
- return false;
- }
- else
- {
- if(helptext != null)
- helptext.innerHTML = "";
- return true;
- }
- }
- </script>
- </head>
- <form method = "post" action="rec.asp" id="rec" name="rec">
- <table>
- <tr>
- <td>
- <input id='pid' name='pid' onblur="validatePID(this,document.getElementById('pid_help'))">
- <span id ="pid_help" class="help" > </span> <br> <br>
- </td>
- <td>
- <select id='loc' name='loc' onblur="validateCB()"> <span id="loc_help">
- <option value = ' ' selected > select location </option>
- <option value = 'abcd' selected > abcd </option>
- <option value = '1234' selected > 1234 </option>
- </td>
- </table>
- </form>
- </html>
dont' know where am i going wrong...
please help !!
thank's....