JQuery验证 - 检查文本框是否具有特殊字符

时间:2014-03-05 12:55:25

标签: jquery asp.net

如何验证textbox Name不包含'@'?

 rules: {
            Name: {
                required: true,

            },
            Email: {
                required: true,
                email: true
            },
            Password1: {
                minlength: 6
            },
 }

1 个答案:

答案 0 :(得分:3)

尝试模式规则

rules: {
    Name: {
        required: true,
        pattern: /^[^@]+$/
    },
    Email: {
        required: true,
        email: true
    },
    Password1: {
        minlength: 6
    },
},
messages: {
    Name: {
        pattern: 'Name should not contain @'
    }
}

演示:Fiddle