aspose file tools*
The moose likes Struts and the fly likes JavaScript Validator Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JavaScript Validator Problem" Watch "JavaScript Validator Problem" New topic
Author

JavaScript Validator Problem

Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
I'm trying to implement JavaScript validations using the Validator Plug-In for Struts. I am only using the standard validations, and they all work fine on the server-side. When I added the <html:javascript ...> tag to the JSP, the JavaScript code appears in the HTML. I hooked it up to the <html:form> onsubmit attribute, and it appears to try to attempt validation, but fails at the following line:

oRequired = new required();

FireFox carps that "required is not defined." IE also does not validate.

I'm somewhat familiar with JavaScript, and I admit that I am lost on what this is trying to do. Am I missing something (like a .js include) that should make this work?

I am using Struts 1.2.4 with Validator 1.1.4 on Tomcat 5.0.30.

Thanks!

Todd Farmer
Todd Farmer
Ranch Hand

Joined: May 28, 2004
Posts: 59
I figured out my problem, so I'm documenting it here in case others encounter the same problem. I was using the 1.0 DTD for the validation.xml and validator-rules.xml. After much searching, I finally found the DTD for 1.1.3 (at http://jakarta.apache.org/commons/dtds/). Upgrading the DTD for these files and obtaining the validator-rules.xml from the most recent Struts sample application in the full source distribution fixed the problems and the JavaScript validation works great now.

Todd Farmer
Java stuff
Greenhorn

Joined: Aug 19, 2005
Posts: 1
Hi all,

I'm facing the same problem. When I"m using <html:javascript>, all the scripts came out on the jsp page. Strange, this will happen only if I use tiles. Else, I won't have this problem.
Paul Chyi
Greenhorn

Joined: Aug 22, 2005
Posts: 1
Hi Todd,

I saw you post a message about how to resolve a struts _javascript validator problem. I'm a newbie at using Struts and bumped into the same problem now. Can I ask you a few question abotu this? I'd really appreciate it if you give me some guidance. Following is the answer you posted.

====================================================================
I figured out my problem, so I'm documenting it here in case others encounter the same problem. I was using the 1.0 DTD for the validation.xml and validator-rules.xml. After much searching, I finally found the DTD for 1.1.3 (at http://jakarta.apache.org/commons/dtds/). Upgrading the DTD for these files and obtaining the validator-rules.xml from the most recent Struts sample application in the full source distribution fixed the problems and the _JavaScript validation works great now.

Todd Farmer
=============================================================

My question is

What do you mean when you said 'Upgrading the DTD for these files' ? Do you just modiedfied xml files or there is more?

Currently my validation.xml and validator-rules.xml files both have a line at the topper part.

<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

Is that all I need or there's more? Do I need to download the validator_1_1_3.dtd file and do something about it?

Hope to hear from you soon. Thanks in advance.

-Paul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript Validator Problem
 
Similar Threads
Client-side validation isn't working for me!!
Struts Validation not working
struts validator. stoping on first validation error.
Validating s:select and s:checkbox with struts2 validator
Clarify on using struts validator and javascript together