I haven't used the validator in a while but I have a 3 questions for you: 1. If, as you say, the Javascript tag isn't being enclosed in <script>..</script> tags, then you need to verify that your validation file is loaded AND that you have the correct form name in your <html:javascript formName="...." />. I've had that problem before when the file either was not loaded (bad path on my part for the plug-in) OR when the formName="..." didn't match anything in my validation.xml file. I recommend you make sure the file loaded properly and is in the correct path specified in your plugIn as you listed a matching formName in that .xml file.
2. Since your html:javascript tag names the form "userForm", why isn't your action tag's onSubmit call this: onsubmit="return validateUserForm(this);" 3. What does your action mapping look like? I should look a bit like this (depending on how you customized it, of course): <action path="/atualizaDadosUsuarioAction" name="userForm" type="AAAA" validate="true" input="BBBB" > <forward name="success" path="????" /> </action> I. The "AAAA" should be the class name of the Action subclass to invoke. II. The validate="true" forces the server-side to user the userForm's validate() method provided by the super class ValidatorForm. This allows validation failure to go to the place specified in the input="BBBB" attribute for your action in the struts-config.xml (or related Struts module) file. III. The "BBBB" should be a place to go (JSP, forward, html page, action) to go to when validation fails. Typically, this is some input form page which is often the page calling the "/atualizaDadosUsuarioAction" Struts action in the first place. Regards, David -----Original Message----- From: Vinicius Carvalho [mailto:[EMAIL PROTECTED] Sent: Friday, October 01, 2004 2:57 PM To: Struts Users Mailing List Subject: Re: Validator Daniel H. F. e Silva wrote: >Hi Gabriel, > > When posting to the struts-users list, please, don't use any language other than english. >It is unpolite as just a few dudes here understand portuguese. > If you and all other Struts dudes (hey, i'm brazilian too) need help with Struts, join the >funkiest irc channel ever: #funkycodemonkey at irc.darkmyst.org. > >Cheers, > Daniel Silva. > > > >--- Gabriel França Campolina <[EMAIL PROTECTED]> wrote: > > > >>Olá Vinicius, >> >>Poste o seu mapeamento de suas action no struts-config, e o mapeamento >>dos seus form, para que eu possa analizar? Verifique o log gerado pelo >>seu container web(Tomcat, JBoss etc), em geral eles listam a maioria >>dos problemas da sua aplicação. >> >>Gabriel F Campolina >>Analista desenvolvedor Java >>Stefanini IT Solutions - BH >> >> >> >>On Thu, 30 Sep 2004 14:33:51 -0300, Vinicius Carvalho >><[EMAIL PROTECTED]> wrote: >> >> >>>Hi there! I've been using Struts for quite sometime, but haven't used >>>the validator yet. >>>So I followed the receipt provided by Struts in Action, but got no >>>success at all. >>> >>>Here's what I've done >>> >>>Struts-config is configured for the right plugin >>>My ActionForm extends ValidatorForm and has no validate() method >>> >>>Validator-rules.xml: >>> >>> <validator name="required" >>> classname="org.apache.struts.validator.FieldChecks" >>> method="validateRequired" >>> methodParams="java.lang.Object, >>> org.apache.commons.validator.ValidatorAction, >>> org.apache.commons.validator.Field, >>> org.apache.struts.action.ActionMessages, >>> javax.servlet.http.HttpServletRequest" >>> msg="validator.errors.required"> >>><javascript> >>> <![CDATA[ >>> function validateRequired(form) { >>> var isValid = true; >>> var focusField = null; >>> var i = 0; >>> var fields = new Array(); >>> oRequired = new required(); >>> for (x in oRequired) { >>> var field = form[oRequired[x][0]]; >>> >>> if (field.type == 'text' || >>> field.type == 'textarea' || >>> field.type == 'file' || >>> field.type == 'select-one' || >>> field.type == 'radio' || >>> field.type == 'password') { >>> >>> var value = ''; >>> >>> // get field's value >>> if (field.type == "select-one") { >>> var si = field.selectedIndex; >>> if (si >= 0) { >>> value = field.options[si].value; >>> } >>> } else { >>> value = field.value; >>> } >>> >>> if (trim(value).length == 0) { { >>> if (i == 0) { >>> focusField = field; >>> } >>> fields[i++] = oRequired[x][1]; >>> isValid = false; >>> } >>> } >>> } >>> >>> if (fields.length > 0) { >>> focusField.focus(); >>> alert(fields.join('\n')); >>> } >>> >>> return isValid; >>> } >>> >>> // Trim whitespace from left and right sides of s. >>> function trim(s) { >>> return s.replace( /^\s*/, "" ).replace( /\s*$/, "" ); >>> } >>> >>> ]]> >>> </javascript> >>> </validator> >>> >>>validation.xml: >>> >>> <form name="userForm"> >>> <field property="nome" depends="required"> >>> <msg name="obrigatorio" key="validator.errors.required"/> >>> <arg0 key="prompt.nome"/> >>> </field> </form> >>>ApplicationResources.properties >>> >>>validator.errors.required= O campo {0} é obrigatório >>>prompt.nome=nome >>> >>>And my jsp file looks like this: >>> >>><html:form action="/atualizaDadosUsuarioAction" name="userForm" >>>type="br.com.auge.errors.action.form.UserForm" onsubmit="return >>>validateRequired(this)"> >>>Nome <html:text property="nome" name="userForm"></html:text><html:errors >>>/><br> >>></html:form> >>><html:javascript formName="userForm"/> >>> >>>Well, what is happening is that after I submit with no values at all, >>>nothing happens, it forwards to the >>>correct path. And also, the javascript generated isn't inside a >>><script></script> block. So it's printed >>>on the page footer. >>> >>>Where did I miss? >>> >>>Thanks >>> >>>Vinicius >>> Well, it does has an error on console, I'm working on that right now, if I don't get any success I'll cry for help again ;) ps: NoSuchMethod Error ... Gotta check my struts.jar versions.... --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]