|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I am using JSP for my Web Page development and in that JSP depending upon the database value, I am creating the form
fields dynamically. How can I validate those fields in Javascript? Is there anyway to access those form fields using javascript? Kindly help me. Thanks in advance. K S SRINIVASAN. |
|
#2
|
||||
|
||||
|
Yes, there are plenty of ways. Can you post your code please?
[The html, not the jsp. View src in your page, and copy/paste the form here...] |
|
#3
|
||||
|
||||
|
In javascript, you could use the document.forms[] array to access your form.
inputList = documents.forms[0].getElementsByTagname('INPUT'); The above line will likely give you an array of Input objects. [if your dynamic form is not the first form on the page, change that index number] |
|
#4
|
||||
|
||||
|
Quote:
Remember the case sensitivity too... ![]() |
|
#5
|
|||
|
|||
|
Hi,
Here I am giving the html code. <html> <head> <title>Order Processing System</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body background="../images/sitebg.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="confmsg();"> <form name="suppq" method="post"> <table align="center" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> <table cellspacing="2" cellpadding="1" border="0" width="100%" align="center"> <tr> <td width="100%" height="100%" align="center" valign="top"> <table width="150" border="0" cellpadding="0" cellspacing="0" class="titlebgcolor"> <tr> <td valign="center"><img src="../images/corner.gif" width="21" height="21" align="absmiddle"> <span valign="center" class="subheadblu">Supplier Quote</span> </td> </tr> </table> </td> </tr> <!--tr><td class="subheadb"> </td></tr--> <tr> <td align="center"> <table width="95%" border="0" cellpadding="1" cellspacing="2" class="bodybgcolor"> <!--tr><td class="subheadb"> </td></tr--> <tr> <td class="subheadb" width="20%" height="21">Enquiry List </td> <td class="subheadb" width="20%" height="21"> <select class="TxtField" name="enqList" onchange="return fnSelect();"> <option value="select">Please Select</option> <option value="IT/0035/05" selected>IT/0035/05</option> <option value="IT/0036/05">IT/0036/05</option> <option value="IT/0037/05">IT/0037/05</option> <option value="IT/0040/05">IT/0040/05</option> </select> </td> <td></td> <td class="subheadb" width="20%" height="21">Supplier List </td> <td class="subheadb" width="20%" height="21"> <select class="TxtField" name="supplierList" onchange="return fnSupSelect();"> <option value="select">Please Select</option> <option value="SP0009" selected>Al Bin</option> <option value="SP0014">Test1</option> <option value="SP0016">Test3</option> </select> </td> </tr> <!--tr><td class="subheadb"> </td></tr--> </table> <input type = "hidden" name = "arraysize" value = "2"> <tr><td align="center"><table width="95%" border="1" cellpadding="1" cellspacing="2" class="bodybgcolor"> <tr> <td>Item</td> <td>Specification</td> <td>Quantity</td> <td>UOM</td> <td>Unit Price</td> <td>Currency</td> <td>Total Price</td> </tr> <tr> <td>Plastic volves </td> <input type="hidden" size="10" class="TxtField" name="itemcd1" value="PLA024"> <td>200 </td> <input type = "hidden" name = "qty1" value = "200"> <td>dasfasdf </td> <td>Litres </td> <td><input type="text" size="15" class="TxtField" name="uprice1" maxlength="12" value="" onBlur="fnCalTot(this,document.suppq.qty1.value,document.s uppq.totprice1)"></td> <td><select class="TxtField" name="currency"> <option value="select">Please Select</option> <option value="AUD">Australlian Dollar</option> <option value="BD">Bahrain Dinar</option> <option value="INR">Indian Rupees</option> <option value="SGD">Singapore Dollar</option> <option value="USD">US Dollar</option> </select></td> <td><input type="text" size="10" class="TxtField" name="totprice1" maxlength="12" value="" readonly></td> <tr> <td>Petrol </td> <input type="hidden" size="10" class="TxtField" name="itemcd2" value="PET025"> <td>200 </td> <input type = "hidden" name = "qty2" value = "200"> <td>asdf </td> <td>Litres </td> <td><input type="text" size="15" class="TxtField" name="uprice2" maxlength="12" value="" onBlur="fnCalTot(this,document.suppq.qty2.value,document.s uppq.totprice2)"></td> <td><select class="TxtField" name="currency"> <option value="select">Please Select</option> <option value="AUD">Australlian Dollar</option> <option value="BD">Bahrain Dinar</option> <option value="INR">Indian Rupees</option> <option value="SGD">Singapore Dollar</option> <option value="USD">US Dollar</option> </select></td> <td><input type="text" size="10" class="TxtField" name="totprice2" maxlength="12" value="" readonly></td> </table> <tr><td align="center"><table width="95%" border="0" cellpadding="1" cellspacing="2" class="bodybgcolor"> <tr> <td class="subheadb" width="80" height="21">Other Charges</td> <td width="244" class="subheadb" height="21"> <input type="text" size="15" class="TxtField" name="och" maxlength="12" value="0.0" onBlur="fnCalTot()"> </td> </tr> <tr> <td class="subheadb" width="80" height="21">Duty</td> <td width="244" class="subheadb" height="21"> <input type="text" size="6" class="TxtField" name="duty" maxlength="6" value=""> </td> <td></td> <td class="subheadb" width="20%" height="21"> Duty Description</td> <td width="35%" class="subheadb" height="21"> <input type="text" size="20" class="TxtField" name="ddesc" maxlength="20" value=""> </td> </tr> <tr> <td class="subheadb" width="80" height="21"><font color="#FF0000">Delivery Period</font></td> <td width="244" class="subheadb" height="21"> <input type="text" size="20" class="TxtField" name="delp" maxlength="20" value=""> </td> <td></td> <td class="subheadb" width="20%" height="21"><font color="#FF0000"> Validity</font></td> <td width="35%" class="subheadb" height="21"> <input type="text" size="10" class="TxtField" name="valid" maxlength="10" value=""> </td> </tr> <tr> <td class="subheadb" width="80" height="21">Manufacturer</td> <td width="244" class="subheadb" height="21"> <input type="text" size="20" class="TxtField" name="manf" maxlength="20" value=""> </td> </tr> <tr> <td class="subheadb" width="80" height="21">Note1</td> <td width="244" class="subheadb" height="21"> <textarea size="16" class="TxtField" name="note1" maxlength="30" cols = 20 value="" rows="2" onchange="return fnTextareaValidation(this,20);"></textarea> </td> <td></td> <td class="subheadb" width="20%" height="21"> Note2</td> <td width="35%" class="subheadb" height="21"> <textarea size="16" class="TxtField" name="note2" maxlength="30" cols = 20 value="" rows="2" onchange="return fnTextareaValidation(this,20);"></textarea> </td> </tr> <tr> <td class="subheadb" width="80" height="21">Payment Terms</td> <td width="244" class="subheadb" height="21"> <textarea size="16" class="TxtField" name="pterms" maxlength="30" cols = 20 value="" rows="2" onchange="return fnTextareaValidation(this,20);"></textarea> </td> <td></td> <td class="subheadb" width="20%" height="21"> Remarks</td> <td width="35%" class="subheadb" height="21"> <textarea size="16" class="TxtField" name="rmks" maxlength="50" cols = 20 value="" rows="2" onchange="return fnTextareaValidation(this,40);"></textarea> </td> </tr> </table></td></tr> <tr> <td align="center" class="subheadb" height="21"> <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('SaveImg','','../images/save_ov.gif',1)"><input name="SaveImg" type="image" src="../images/save_n.gif" border="0" alt="Save" width="54" height="19" onClick="return fnSave();"></a> <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('cl','','../images/cancel_ov.gif',1)"><input name="cl" type="image" src="../images/cancel_n.gif" border="0" width="70" height="19" alt="Cancel" onClick="return fnReset();"></a> <comment> <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('c2','','../images/back_ov.gif',1)"><input name="c2" type="image" src="../images/back_n.gif" border="0" width="70" height="19" alt="Back" onClick="return fnBack();"></a> </comment> <input type = "button" value = "Display" class = "subheadbn1" onClick = "fnDisplay()"> <!--a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('c3','','../images/print_ov.gif',1)"><input name="c2" type="image" src="../images/print_n.gif" border="0" width="70" height="19" alt="Print" onClick="return fnPrint();"></a--> </td> </tr> </table> </td></tr> </table> </form> </body> </html> Kindly go through the same and help me to resolve. Thanks. Srinivasan. Quote:
|
|
#6
|
|||
|
|||
|
Thanks for the reply. I will try it out and come back to you.
Srinivasan. Quote:
|
|
#7
|
|||
|
|||
|
Thanks for the reply. I will try it out and come back to you.
Srinivasan. Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Dynamic Form Fields validation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|