<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-html-el.tld" prefix="html_el" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

   <html>
   <head>
       <title>Listing all cities</title>
	   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   </head>

   <body>
     <center><h3>city List</h3></center>
	 </body>
	  <html:form action="/UpdateSuccessAction.do" >
		 <c:forEach var="obj" items="${myBean.result}">
		 City: <c:out value='${obj.cn}' /><br>
		 Pincode: <html_el:text property="pcList" value="${obj.pc}"/><br><br>
		</c:forEach>
		<input type="submit" name="submit" value="save111" onClick="return validpincode(); onSave()">
		<p><a href="HomePage.do">HomePage</a></p>
	  </html:form>
	  </html>
	  <script>
function onSave()
{
	document.forms[0].action="UpdateSuccessAction.do";
	document.forms[0].submit();
}

Hi i want the numeric validation of all the pcList values coming from Database in this update jsp which upon clicking save will get saved in the database.I am able to save the values in the database but not able to write(or perform) the required numeric validation javascript.

Please any help would be great.

Thanks Vishal

By numeric validation do u just want to validate that numeric characters were entered in the form?

Ya i just wanted to validate only numeric characters.

but I did it.Thanks for the reply neways.

For other's refernce.This is what i did.

function validpincode()
{
	var len = document.forms[0].pcList.length;
	for(i=0;i<len;i++)
	{
		var s=document.forms[0].pcList[i].value;
		var regInt = /^[0-9]+$/;
		if(!regInt.test(s))
		{
			alert("please enter numeric value");
			document.forms[0].pcList[i].focus();
			return false;
		}
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.