• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript Validator Problem

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic