This project is read-only.

Custom Rule Client side

Sep 29, 2009 at 4:15 AM

Hi there, hopefully someone can help me.

I have form for which I would like to perform some custom validation which only occurs on the client side (specifically conditional validation)

On my mvc view I am hooking up the validation as follows

			.AddRule(UserAccount.SelfIssuePurchasePriceField, new CustomRule("SelfIssueRequiredRule", new object(), "an error message"))
			.AddRule(UserAccount.EmailAddressField,new DataTypeRule(DataTypeRule.DataType.EmailAddress))%>
    <% } %>

SelfIssueRequiredRule is a javascript function defined as follows
	function SelfIssueRequiredRule(value, element, params){
		var value = $("#<%=UserAccount.SelfIssuePurchasePriceField %>").attr('value');
		return $('input[name=isReseller]').is(':checked') && value.length!=0;
The reason i am not passing any parameters because i can do everything i need to from within javascript. The alert is just for debugging.

Can somebody see what I am doing wrong, as the custom validation function is never called while the data type rule works fine.

Thank you