﻿//Source: http://www.codeproject.com/cs/miscctrl/FireCustomValidatorAlways.asp?df=100&forumid=165028&exp=0&select=1074227

//OVERRIDE THE NORMAL VALIDATOR FRAMEWORK
function CustomValidatorEvaluateIsValid(val) {
    var value = "";
    if (typeof(val.controltovalidate) == "string") {
        value = ValidatorGetValue(val.controltovalidate);
        //make it fire always
        //if (ValidatorTrim(value).length == 0)
        //    return true;
    }
    var args = { Value:value, IsValid:true };
    if (typeof(val.clientvalidationfunction) == "string") {
        eval(val.clientvalidationfunction + "(val, args) ;");
    }        
    return args.IsValid;
}
function RegularExpressionValidatorEvaluateIsValid(val) {
    var value = ValidatorGetValue(val.controltovalidate);
    //make it fire always
    //if (ValidatorTrim(value).length == 0)
    //    return true;        
    var rx = new RegExp(val.validationexpression);
    var matches = rx.exec(value);
    return (matches != null && value == matches[0]);
}