Film Noir
Jun 9th, 2008, 04:40 PM
Greetings,
I'm fairly new to Spring and struggling to get client-side validation working correctly.
I've managed to get server-side validation working correctly, but the same configuration will not work for client-side.
I've been following chapter 17 of the springmodules docs (it won't let me post a link):
I've added the validation tag library, and added the javascript tag and modified the onSubmit function of the form:
<validator:javascript formName="vendor" staticJavascript="false" xhtml="true" cdata="false"/>
....
<form:form name="vendor" method="post" action="vendor/updateProfile.htm" commandName="userVendor" enctype="multipart/form-data" onsubmit="return validateVendor(this)">
When I view the page source this is the generated javascript:
<script type="text/javascript">
var bCancel = false;
function validateVendor(form) {
if (bCancel)
return true;
else
return validateEmail(form);
}
function email() {
this.aa = new Array("contactEmail", "errors.email", new Function ("varName", " return this[varName];"));
}
</script>
The problem is when I submit the form - it throws a 'validateEmail() is not defined' error. It can't locate the validateEmail() function defined in the validator-rules.xml ?
Has anyone any ideas why this may be happening? It there an extra javascript file I need to import into the page?
I've defined the following validation.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD
Commons Validator Rules Configuration 1.1//EN"
"...../validator_1_3_0.dtd">
<form-validation>
<formset>
<field property="contactEmail" depends="required,email">
<arg key="error.vendorEmail" />
</field>
</form>
</formset>
</form-validation>
Thanks,
Alan.
I'm fairly new to Spring and struggling to get client-side validation working correctly.
I've managed to get server-side validation working correctly, but the same configuration will not work for client-side.
I've been following chapter 17 of the springmodules docs (it won't let me post a link):
I've added the validation tag library, and added the javascript tag and modified the onSubmit function of the form:
<validator:javascript formName="vendor" staticJavascript="false" xhtml="true" cdata="false"/>
....
<form:form name="vendor" method="post" action="vendor/updateProfile.htm" commandName="userVendor" enctype="multipart/form-data" onsubmit="return validateVendor(this)">
When I view the page source this is the generated javascript:
<script type="text/javascript">
var bCancel = false;
function validateVendor(form) {
if (bCancel)
return true;
else
return validateEmail(form);
}
function email() {
this.aa = new Array("contactEmail", "errors.email", new Function ("varName", " return this[varName];"));
}
</script>
The problem is when I submit the form - it throws a 'validateEmail() is not defined' error. It can't locate the validateEmail() function defined in the validator-rules.xml ?
Has anyone any ideas why this may be happening? It there an extra javascript file I need to import into the page?
I've defined the following validation.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD
Commons Validator Rules Configuration 1.1//EN"
"...../validator_1_3_0.dtd">
<form-validation>
<formset>
<field property="contactEmail" depends="required,email">
<arg key="error.vendorEmail" />
</field>
</form>
</formset>
</form-validation>
Thanks,
Alan.