1

I'm just trying to do something along those lines here with ScriptSharp:

$('#yourform').bind('change keyup', function() {
    if($(this).validate().checkForm()) {
        // do something
    }
});

(see https://stackoverflow.com/a/6072997/465509)

But I can't seem to figure out how to use the jQueryValidator object.

This is my approach so far:

namespace TestSite.Script.Validation
{
    internal class FormValidationSetup
    {
        internal FormValidationSetup()
        {
            jQuery.OnDocumentReady(delegate
            {
                jQuery.Select("#yourform").Bind("change keyup", delegate(jQueryEvent @event)
                {
                    jQueryValidator validator = (jQueryValidator) System.Script.Literal("{0}.validate()", jQuery.FromElement(@event.Target));
                    if (validator.ValidateForm())
                    {
                        // do something
                    }
                });
            });
        }
    }
}

But that throws some odd errors:

Error 3 Check that your C# source compiles and that you are not using an unsupported feature. Common things to check for include use of fully-qualified names (use a using statement to import namespaces instead) or accessing private members of a type from a static member of the same type.

(I'm using ScriptSharp 0.8)

Any help is appreciated.

-- edit --

Added namespace in the sample above, since it seems to cause the error.

1 Answer 1

2

Try the following:

jQuery.FromElement(e.Target).Plugin<jQueryValidationObject>().Validate();

Hope that helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.