Thursday, February 10, 2011

RSV Prototype Example

I'm trying to get Ben Keen's RSV for Prototype working. I found a suggestion for Ben Keen's component but, I'm having trouble getting it working with Prototype. Here is my code, it doesn't seem to be working. The error is RSV isn't a function. I'm not sure how to translate the jQuery example to Prototype.

function DomLoaded() {
    var mainForm = document.forms[0];

    try {
        mainForm.RSV({
            onCompleteHandler: OnComplete,
            rules: ["required,txtEmailAddress,Please Enter an email addresss"]
        });
    }
    catch (err) {
        alert(err);
    }

     alert("dom:loaded");
};

function OnComplete()
{
    alert("Complete.");

    //Stops Form from submitting
    return false;
}
  • I fixed this code myself. Here is the answer:

    function DomLoaded() {
        try {
        var myRSV = new RSV({
            formID:"aspnetForm",
            onCompleteHandler: OnComplete,
            rules: ["required,txtEmailAddress,Please Enter an email addresss"]
            });
        }
        catch (err) {
            alert(err);
        }
    
        alert("dom:loaded");
    };
    
    function OnComplete()
    {
        alert("Complete.");
    
        //Stops Form from submitting
        return false;
    }
    
    From Sam

0 comments:

Post a Comment