Multiple field validations using javascript

Thread Solved

Join Date: Oct 2009
Posts: 10
Reputation: vishalanuj is an unknown quantity at this point 
Solved Threads: 0
vishalanuj vishalanuj is offline Offline
Newbie Poster

Multiple field validations using javascript

 
0
  #1
Oct 22nd, 2009
  1. <%@ page language="java" pageEncoding="ISO-8859-1"%>
  2. <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
  3. <%@taglib uri="/WEB-INF/struts-html-el.tld" prefix="html_el" %>
  4. <%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
  5. <%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
  6. <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
  7.  
  8. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  9.  
  10. <html>
  11. <head>
  12. <title>Listing all cities</title>
  13. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  14. </head>
  15.  
  16. <body>
  17. <center><h3>city List</h3></center>
  18. </body>
  19. <html:form action="/UpdateSuccessAction.do" >
  20. <c:forEach var="obj" items="${myBean.result}">
  21. City: <c:out value='${obj.cn}' /><br>
  22. Pincode: <html_el:text property="pcList" value="${obj.pc}"/><br><br>
  23. </c:forEach>
  24. <input type="submit" name="submit" value="save111" onClick="return validpincode(); onSave()">
  25. <p><a href="HomePage.do">HomePage</a></p>
  26. </html:form>
  27. </html>
  28. <script>
  29. function onSave()
  30. {
  31. document.forms[0].action="UpdateSuccessAction.do";
  32. document.forms[0].submit();
  33. }
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 10
Reputation: vishalanuj is an unknown quantity at this point 
Solved Threads: 0
vishalanuj vishalanuj is offline Offline
Newbie Poster
 
0
  #2
Oct 22nd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 318
Reputation: Thirusha is an unknown quantity at this point 
Solved Threads: 51
Thirusha's Avatar
Thirusha Thirusha is offline Offline
Posting Whiz
 
0
  #3
Oct 22nd, 2009
By numeric validation do u just want to validate that numeric characters were entered in the form?
Life... Is a Moment
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 10
Reputation: vishalanuj is an unknown quantity at this point 
Solved Threads: 0
vishalanuj vishalanuj is offline Offline
Newbie Poster
 
0
  #4
Oct 22nd, 2009
Ya i just wanted to validate only numeric characters.

but I did it.Thanks for the reply neways.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 10
Reputation: vishalanuj is an unknown quantity at this point 
Solved Threads: 0
vishalanuj vishalanuj is offline Offline
Newbie Poster
 
0
  #5
Oct 22nd, 2009
For other's refernce.This is what i did.
  1. function validpincode()
  2. {
  3. var len = document.forms[0].pcList.length;
  4. for(i=0;i<len;i++)
  5. {
  6. var s=document.forms[0].pcList[i].value;
  7. var regInt = /^[0-9]+$/;
  8. if(!regInt.test(s))
  9. {
  10. alert("please enter numeric value");
  11. document.forms[0].pcList[i].focus();
  12. return false;
  13. }
  14. }
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 450 | Replies: 4
Thread Tools Search this Thread



Tag cloud for JSP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC