• 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

Problem with validation 'required' attributes

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose this case. I'm using Validator framework. So, I have a form with two e-mail fields and javascript validation on.

In validation.xml file I defined for the first e-mail field depends="required,email", and for the second e-mail field depends="email".
But, the result is the same. Both fields are "required".

What I want in my JSP is validation against second e-mail field only if it was not empty. I don't want javascript message "Invalid e-mail format" on an empty e-mail field.

Is there any way to overcome this problem?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doublecheck in validator-rules.xml that email does not depend on required.
You want it to be depends=""
 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I've already figured out that.
I will make a new entry for email validation (e.g. email2, with depends set to "").
Thanks for the answer again!
[ August 20, 2004: Message edited by: Velika Srbija ]
 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another chained problem.
------------------------

After entering new validation-rule named 'email2' with 'depends' parameter set to "":

<validator name="email2"
classname="org.apache.struts.util.StrutsValidator"
method="validateEmail"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.email">
<javascript><![CDATA[
function validateEmail(form) {
... ...
(here is the same code as in the 'email' validation-rule; no changes)
... ...


almost everythhing works OK. Validation works as expected, but there is no JavaScript ALERT message for incorrect input.
I have tried to modify JavaScript code in order to fix this problem, but failed every time.

What is the problem?
 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pomoz Bog brate Srbine. Let's see if I can help here.
Well now that struts part is working, javascript is the only thing that's left to troubleshoot now, right? That should be an easy part. Why don't you look at the resulting page and it's source. Treat it as pure html and just troubleshoot javascript part.
 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bog ti pomogo sokole. Da mi ti ne rece sta da radim, ja se nikad sam ne bi' setio.

I've already done what you said. No result.
Why don't you try yourself. Only small modifications in any code that uses Validator plug-in are needed in order to test this.
[ August 22, 2004: Message edited by: Velika Srbija ]
 
Right! We're on it! Let's get to work tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic