Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript Validator Problem

 
Todd Farmer
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic