开发者

change error message of live validation

开发者 https://www.devze.com 2023-02-28 06:36 出处:网络
var Validate = { /** *validates that the field has been filled in * *@var value {mixed} - value to be checked
var Validate = {

/**
 *  validates that the field has been filled in
 *
 *  @var value {mixed} - value to be checked
 *  @var paramsObj {Object} - parameters for this particular validation, see below for details
 *
 *  paramsObj properties:
 *                          failureMessage {String} - the message to show when the field fails validation 
 *                                                    (DEFAU开发者_StackOverflowLT: "Can't be empty!")
 */
Presence: function(value, paramsObj){
    var paramsObj = paramsObj || {};
    var message = paramsObj.failureMessage || "Can't be empty!";
    if(value === '' || value === null || value === undefined){ 
        Validate.fail(message);
    }
    return true;
},

actually i tried to change paramobj in here what i wrote is

    try{
        Validate.Presence(true,{ failureMessage: "You must be true!" })
    }catch(err){
        alert(err.description);
    }

why is it return alert undefined? what cause the error?


Try using:

 alert(err.message);
0

精彩评论

暂无评论...
验证码 换一张
取 消