You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rabin Aryal <ra...@netlert.com> on 2008/11/18 15:48:52 UTC
Client Side Validation Not Working
Guys,
I don't know what I am doing wrong. I am missing the actual validation
JavaScript code in the generated html when accessing
add_comment.do?blogid=23. I have included the snippet below.
addcomment.jsp
<s:form action="save_comment" method="POST" validate="true">
<s:actionerror />
<s:actionmessage />
<input type="hidden" id="blogid" name="comment.blogid" value="<s:property
value="blog.id">"
<s:textfield required="true" id="name" name="comment.name" label="Name"/>
<s:textarea required="true" id="comment" name="comment.comment"
label="Comment"/>
<s:submit/>
struts.xml
<action name="add_comment" class="CommentAction" method="add">
<result>/blog/addcomment.jsp</result>
</action>
<action name="save_comment" class="CommentAction" method="save">
<result name="input">/blog/addcomment.jsp</result>
<result>/blog/addcomment.jsp</result>
</action>
CommentAction-save-validation.xml
<validators>
<field name="comment.name">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>Name is required</message>
</field-validator>
</field>
<field name="comment.comment">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>Comment is required</message>
</field-validator>
</field>
</validators>
Generated html by browser when accessing add_comment.do?blogid=23
<form namespace="/blog"
id="save_comment" name="save_comment" onsubmit="return
validateForm_save_comment();"
action="/blog/save_comment.action" method="POST">
.......
.......
.......
function validateForm_save_comment()
{
form = document.getElementById("save_comment");
clearErrorMessages(form);
clearErrorLabels(form);
var errors = false;
// Missing actual validation here..............
return !errors;
}
I would really appreciate is anyone has idea what am I doing wrong.
Thanks
Rabin
RE: Client Side Validation Not Working
Posted by Rabin Aryal <ra...@netlert.com>.
Lukasz,
Thanks a lot. I changed the action name and then what a silly
mistake...........
Rabin
-----Original Message-----
From: Lukasz Lenart [mailto:lukasz.lenart@googlemail.com]
Sent: Tuesday, November 18, 2008 10:31 AM
To: Struts Users Mailing List
Subject: Re: Client Side Validation Not Working
And the server-side validation is working? I think not, name of xml is
not as it should be - it should be
CommentAction-save_comment-validation.xml
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Client Side Validation Not Working
Posted by Lukasz Lenart <lu...@googlemail.com>.
And the server-side validation is working? I think not, name of xml is
not as it should be - it should be
CommentAction-save_comment-validation.xml
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org