Thanks for the response, I am using an Action flavour of ValidatorForm Niall ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Thursday, November 11, 2004 7:59 PM Subject: Re: Does Javascript Validation work with mapping path as key? > > One other thing to check, I think name="myForm" has to be type of > ValidatorActionForm, not the usual ValidatorForm. > > Bart > > "Niall Pemberton" > <niall.pemberton@ > blueyonder.co.uk> To > "Struts Users Mailing List" > 11/11/2004 02:23 <[EMAIL PROTECTED]> > PM cc > > > I'm trying to get javascript validation working using the action mapping's > path as the validation key with Struts 1.2.4. > > I don't usually use js (I'm trying to test something) but the generated > javascript doesn't appear to work - from where I'm sitting it looks broken > - > can anyone confirm if they have it working or not? > > I have the following mapping in my struts config: > > <action path="/houseTypeAdd" type="....." > name="myForm" scope="request" validate="true" input="housetype.add"> > ... > </action> > > And my jsp has the following form & javascript tags: > > <html:form action="houseTypeAdd" focus="housetype_code" > onsubmit="return validateHouseTypeAdd(this);"> > ... > </html:form> > <html:javascript formName="houseTypeAdd" bundle="niall-1"/> > > There are three fields defined as 'required' and it genertes a javascript > function called houseTypeAdd_required () - however when I put an alert in > the required.js script it seems to be trying to call function named after > the form rather than the mapping (i.e. myForm_required()) - so its using > the > form name rather than the mappings path. > > Can anyone see what I'm doing wrong or confirm it doesn't work? Below is > relevant detail of the javascript being generated > > Thanks > > Niall > > function validateHouseTypeAdd(form) { > if (bCancel) > return true; > else > var formValidationResult; > formValidationResult = validateRequired(form); > return (formValidationResult == 1); > } > function houseTypeAdd_required () { > this.a0 = new Array("housetype_code", "[Bundle 1] custom {0} is > required.", new Function ("varName", " return this[varName];")); > this.a1 = new Array("housetype_short_desc", "[Bundle 1] custom [Bundle > 2] > short-desc-msg is required.", new Function ("varName", " return > this[varName];")); > this.a2 = new Array("housetype_desc", "[Bundle 1] custom [Bundle 1] > description-msg is required.", new Function ("varName", " return > this[varName];")); > } > function validateRequired(form) { > var isValid = true; > var focusField = null; > var i = 0; > var fields = new Array(); > var formName = form.getAttributeNode("name"); > alert("validateRequired(form): about to call method: " + formName.value > + > "_required()"); > oRequired = eval('new ' + formName.value + '_required()'); > for (x in oRequired) { > ... > > > > --------------------------------------------------------------------- > 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] > >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]