Demetrice Printzk
New Member
I am trying to use the customvalidator object and I am have having no luck. The script I wrote works fine - no errors; however, when I use the CV it throws an error - (Line: 316 object expected).<BR><BR>I did some research and noticed that you need to pass (source, arguments). I return arguments.IsValid = true ... etc. Here is a sample of the code in JS/ASP.net.<BR><BR>JS:<BR> function validateCC(source, arguments) {<BR> if (arguments.value%2 == 0) {<BR> arguments.IsValid = true;<BR> } else {<BR> arguments.IsValid = false;<BR> }<BR> }<BR><BR>ASP.net<BR><asp:CustomValidator<BR> ID="CVccNumber" <BR> Runat="server"<BR> ControlToValidate="ccNumber"<BR> ClientValidationFunction="validateCC"<BR> ErrorMessage="*"<BR>/><BR><BR>If you see something or know of any bugs - please let me know. <BR><BR>Thanks,<BR>ToddJavascript, being case-sensitive, needs 'Value' to be accessed with a capital 'V'.<BR><BR><BR><BR>function validateCC(source, arguments)<BR>{ <BR> // always helps to do a bit of debugging <BR> alert(typeof(source)) ;<BR> alert(typeof(arguments)) ;<BR> // note that the Value property of the arguments<BR> // class is spelt with a capital 'V'<BR> alert(arguments.Value) ;<BR> <BR> if (arguments.Value%2 == 0)<BR> { <BR> arguments.IsValid = true ; <BR> } else { <BR> arguments.IsValid = false ; <BR> } <BR>}I too am experiencing problems with the CustomValidator using JScript. My code:<BR><BR>function ValidateLength(source, args)<BR>{ <BR> if (len(args.value) < 3)<BR> {<BR> args.IsValid = false;<BR> }<BR> else<BR> {<BR> args.IsValid = true;<BR> }<BR>}<BR><BR>Here's where it gets weird. It seems that the Validator is trying to fire off the script on a OnBlur() event (when the focus leaves the textbox). This chucks a "Object expected" error. Whats screwy is that when the form is posted the Validator fires off again without any errors and performing all the validations correctly. Frankly this pisses me off. Examples ripped from Microsofts site are error the same way. <BR><BR>-rpeters