JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old April 3rd, 2005, 12:36 AM
kssvasan kssvasan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 5 kssvasan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 55 sec
Reputation Power: 0
Question Dynamic Form Fields validation

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.

Reply With Quote
  #2  
Old April 3rd, 2005, 04:26 AM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: I have emerged from the place of spells and fairies
Posts: 97 ChiefWigs1982 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 17 h 35 m 12 sec
Reputation Power: 4
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...]

Reply With Quote
  #3  
Old April 4th, 2005, 08:03 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
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]

Reply With Quote
  #4  
Old April 4th, 2005, 11:52 AM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: I have emerged from the place of spells and fairies
Posts: 97 ChiefWigs1982 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 17 h 35 m 12 sec
Reputation Power: 4
Quote:
Originally Posted by MadCowDzz
inputList = document.forms[0].getElementsByTagName('INPUT');
-------------------------------------------------------------^

Remember the case sensitivity too...

Reply With Quote
  #5  
Old April 4th, 2005, 11:51 PM
kssvasan kssvasan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 5 kssvasan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 55 sec
Reputation Power: 0
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">&nbsp;</td></tr-->
<tr>
<td align="center">
<table width="95%" border="0" cellpadding="1" cellspacing="2" class="bodybgcolor">
<!--tr><td class="subheadb">&nbsp;</td></tr-->
<tr>
<td class="subheadb" width="20%" height="21">Enquiry List </td>
<td class="subheadb" width="20%" height="21">&nbsp;&nbsp;
<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">&nbsp;</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&nbsp;</td>
<input type="hidden" size="10" class="TxtField" name="itemcd1" value="PLA024">
<td>200&nbsp;</td>
<input type = "hidden" name = "qty1" value = "200">
<td>dasfasdf&nbsp;</td>
<td>Litres&nbsp;</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&nbsp;</td>
<input type="hidden" size="10" class="TxtField" name="itemcd2" value="PET025">
<td>200&nbsp;</td>
<input type = "hidden" name = "qty2" value = "200">
<td>asdf&nbsp;</td>
<td>Litres&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" size="6" class="TxtField" name="duty" maxlength="6" value="">
</td>
<td></td>
<td class="subheadb" width="20%"
height="21">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Duty Description</td>
<td width="35%" class="subheadb" height="21">&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Validity</font></td>
<td width="35%" class="subheadb" height="21">&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Note2</td>
<td width="35%" class="subheadb" height="21">&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Remarks</td>
<td width="35%" class="subheadb" height="21">&nbsp;&nbsp;
<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>&nbsp;
<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>&nbsp;
<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>&nbsp;</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-->&nbsp;
</td>
</tr>
</table>
</td></tr>
</table>
</form>
</body>
</html>


Kindly go through the same and help me to resolve.

Thanks.

Srinivasan.


Quote:
Originally Posted by Agent47
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...]

Reply With Quote
  #6  
Old April 4th, 2005, 11:52 PM
kssvasan kssvasan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 5 kssvasan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 55 sec
Reputation Power: 0
Thanks for the reply. I will try it out and come back to you.

Srinivasan.
Quote:
Originally Posted by Agent47
Remember the case sensitivity too...

Reply With Quote
  #7  
Old April 4th, 2005, 11:53 PM
kssvasan kssvasan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 5 kssvasan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 58 m 55 sec
Reputation Power: 0
Thanks for the reply. I will try it out and come back to you.

Srinivasan.

Quote:
Originally Posted by MadCowDzz
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]

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Dynamic Form Fields validation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway