gpt4 book ai didi

javascript - 更改实时验证的错误消息

转载 作者:行者123 更新时间:2023-11-30 06:46:53 25 4
gpt4 key购买 nike

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
* (DEFAULT: "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;
},

实际上我试图在这里更改 paramobj我写的是

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

为什么它返回未定义的警报?错误原因是什么?

最佳答案

尝试使用:

 alert(err.message);

关于javascript - 更改实时验证的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5739147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com