struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiru <>
Subject Validating Struts2 fields using JQuery
Date Tue, 28 Apr 2009 14:46:01 GMT
I am using JQuery for validating the fields in my jsp page, created using
Struts 2.1.6. But the jquery validation is
not firing and the form is getting submitted. In the same page I have
created tabs, date picker using JQuery and
they are all working fine. The same JQuery validtion is working fine with
pure html (no struts tag) form. The fields
 that i am trying to validate are inside the jquery tab. Any idea what could
be missing/wrong?


Here is portion of my  .jsp
<%@ taglib prefix="s" uri="/struts-tags"%>
<link type="text/css" href="/abc/css/jquery-ui-1.7.1.custom.css"
rel="stylesheet" />
<script type="text/javascript" src="/abc/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="
<script type="text/javascript"
<link rel="stylesheet" type="text/css" href="../css/validate.css" />

<script type="text/javascript">
$(document).ready(function() {
  // validate signup form
   rules: {
    myForm_userId: "required",
   messages: {
    myForm_userId: "Enter user ID",

   // the errorPlacement has to take the table layout into account
    errorPlacement: function(error, element) {
    if (":radio") )
     error.appendTo( element.parent().next().next() );
    else if (":checkbox") )
     error.appendTo ( );
     error.appendTo( element.parent().next() );
   // specifying a submitHandler prevents the default submit, good for the
                    /*  submitHandler: function() {
   }, */
   success: function(label) {
    // set &nbsp; as text for IE


 <s:form name="myForm" id="myForm" action="myResults"
 namespace="/" method="post" theme="xhtml">

 <table align="center" border="0">
 <table align="center">

      <td colspan="2">
      <s:fielderror cssClass="error">
       <s:param value="userID" />
     <s:textfield name="userID"
      label="%{getText('login.label.userID')}" required="true"
      requiredposition="left" maxlength="10">
      <s:param name="labelstyle" value="%{'boldtext'}" />


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message