Hi All, 
 
I have just started using the requiredif validation rule. The server
side validation is working fine but the client side JavaScript has
errors for my requiredif form fields. 
My form field requires the feild button2URL only if button2Lbl has been
entered and if button2URL it must pass the mask rule. I am by no means a
JavaScript expert but I think I can identify where the problem is. 
 
When I use my mask without the requiredif rule all is well in client
JavaScript the generated method is as follows:
 
function mask () { 
     this.aa = new Array("button2URL", "Button 2 URL must contain a
valid URL. For more information click the help icon.", new Function
("varName", "this.mask=/^http:\\/\\/|^file:\\/\\/|^mailto:[^ ]*$/;
return this[varName];"));
    } 
 
When the requiredif rule is added and the JavaScript breaks and the
generated method is:
 
function mask () { 
     this.aa = new Array("button2URL", "Button 2 URL must contain a
valid URL. For more information click the help icon.", new Function
("varName", "this.field-test[0]='NOTNULL'; this.field[0]='button2Lbl';
this.mask=/^http:\\/\\/|^file:\\/\\/|^mailto:[^ ]*$/;  return
this[varName];"));
    } 
 
As the case may be I have probably confiured my validation rule wrong so
below is my validation def for this form:

<field property="button2Lbl" depends="required">

<arg0 key="wbConfigForm.button2Lbl"/>

</field>

<field property="button2URL" depends="requiredif,mask">

<msg name="mask" key="error.invalidURL"/>

<arg0 key="wbConfigForm.button2URL"/>

<var>

<var-name>mask</var-name>

<var-value>^http:\/\/|^file:\/\/|^mailto:[^ ]*$</var-value>

</var>

<var>

<var-name>field[0]</var-name>

<var-value>button2Lbl</var-value>

</var>

<var>

<var-name>field-test[0]</var-name>

<var-value>NOTNULL</var-value>

</var> 

</field>

</form>

I have accepted that for now I will create my own static JavaScript for
the form to handle the requirdif fields but I would still like to use
the other rules and their client side validation with my reqiredif
fields. Is there anyway I can achieve this. Even though my server side
validation is ok, I cant publish these pages with JavaScript errors on
form post. So if I cant correct this bug I will have to remove this
fields validation from the validator :-(.

Many thanks,

Greg

 

 

 

Reply via email to