Results 1 to 11 of 11
  1. #1
    ashish1987 is offline Member
    Join Date
    Apr 2012
    Location
    Delhi
    Posts
    10
    Rep Power
    0

    Default jquery validation

    hello friends ,
    i am using jquery validation in select box of struts2 , but validation not working when i uses headerkey="-1".
    please give me a solution if you have......
    thank you....

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jquery validation

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: jquery validation

    Far too vague.
    Without anything to see there is going to be next to no way of saying what the problem is.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    ashish1987 is offline Member
    Join Date
    Apr 2012
    Location
    Delhi
    Posts
    10
    Rep Power
    0

    Default Re: jquery validation

    Java Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@taglib uri="/struts-tags" prefix="s"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    		
    		<script src="${pageContext.request.contextPath}/templet_content/js/jquery.js" type="text/javascript"></script>
    		<script src="${pageContext.request.contextPath}/templet_content/js/jquery.validate.js" type="text/javascript"></script>
    		<script type="text/javascript">
    			$(document).ready(function(){
    			$('#form').validate({
    					rules:
    					{
    						n1:"required",
    						n2:"required",
    					},
    					messages:
    					{
    						n1:"select option",
    						n2:"select option",
    					}
    				});
    			
    			});
    </script>
    </head>
    <body>
    <s:form id="form">
    	<s:select list="{'A','B','C'}" name="n1" headerKey="-1" headerValue="--Select--"/>
    	<s:select list="{'1','2','3'}" name="n2" headerKey="" headerValue="--Select--"/>
    	<s:submit/>
    </s:form>
    </body>
    </html>

    In this code i am using jquery validation in select box of struts2.
    As the above, when headerkey="" then validation works.......
    but when headerkey="-1" then validation does not work.......
    if anybody have a solution, please post in this thread ....
    thank you..

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: jquery validation

    What does the validation do when the headerKey is '-1'?
    Also show the resulting HTML from the two struts tags.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    ashish1987 is offline Member
    Join Date
    Apr 2012
    Location
    Delhi
    Posts
    10
    Rep Power
    0

    Default Re: jquery validation

    jquery validation-output.png

    In this First select box have headerkey="-1", so they don't show message...and validation does not work...

    In this Second select box have headerkey="", so there jquery validation works properly...
    Last edited by ashish1987; 05-24-2012 at 08:57 PM.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: jquery validation

    No, that's not the HTML, that's a screen shot.
    I want the source that appears on the client.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    ashish1987 is offline Member
    Join Date
    Apr 2012
    Location
    Delhi
    Posts
    10
    Rep Power
    0

    Default Re: jquery validation

    HTML code show in fourth post....

  9. #9
    ashish1987 is offline Member
    Join Date
    Apr 2012
    Location
    Delhi
    Posts
    10
    Rep Power
    0

    Default Re: jquery validation

    Java Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
    <title>Insert title here</title>
    <script type="text/javascript" src="/_sctech2/templet_content/js/jquery.js">
    <script type="text/javascript" src="/_sctech2/templet_content/js/jquery.validate.js">
    <script type="text/javascript">
    $(document).ready(function(){
    $('#form').validate({
    rules:
    {
    n1:"required",
    n2:"required",
    },
    messages:
    {
    n1:"select option",
    n2:"select option",
    }
    });
    });
    </script>
    </head>
    <body>
    <form id="form" method="post" action="/_sctech2/test.jsp;jsessionid=088B0B261E34CD91C219DF2C6C8B047B" name="form" novalidate="novalidate">
    <table class="wwFormTable">
    <tbody>
    <tr>
    <td class="tdLabel"></td>
    <td>
    <select id="form_n1" class="valid" name="n1">
    <option value="-1">--Select--</option>
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
    </select>
    </td>
    </tr>
    <tr>
    <td class="tdLabel"></td>
    <td>
    <select id="form_n2" class="error" name="n2">
    <option value="">--Select--</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    <label class="error" for="form_n2" generated="true">select option</label>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <div align="right">
    <input id="form_0" type="submit" value="Submit">
    </div>
    </td>
    </tr>
    </tbody>
    </table>
    </form>
    </body>
    </html>
    This is client side html code...

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: jquery validation

    OK.
    Why do you think the validator should view "-1" as an invalid selection?
    I can understand "" because it has no value, but "-1" does and so I am not sure why you think it should be flagging that?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  11. #11
    ashish1987 is offline Member
    Join Date
    Apr 2012
    Location
    Delhi
    Posts
    10
    Rep Power
    0

    Default Re: jquery validation

    actually i want, if option value is "-1",then that is show validation error when field is empty..

Similar Threads

  1. Jquery validation in struts with ajax
    By ashish1987 in forum Struts
    Replies: 6
    Last Post: 04-21-2012, 10:19 AM
  2. Jquery pop out script
    By fOmey in forum New To Java
    Replies: 1
    Last Post: 12-03-2010, 02:13 AM
  3. JQuery Menus
    By anithajerome in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-01-2010, 10:28 AM
  4. struts2 with jquery
    By amma2009 in forum Advanced Java
    Replies: 10
    Last Post: 11-16-2010, 09:07 AM
  5. jQuery 1.2.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 10-25-2007, 04:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •