jQuery Validation plugin in ASP.NET Web Forms

后端 未结 11 2108
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 14:56

I would really like use the jQuery Validation plugin in my ASP.NET Web Forms application (not MVC). I find it easier than adding asp validators everywhere and setting the co

11条回答
  •  我在风中等你
    2020-11-27 15:19

    The best solution is use "<%=tbUsername.UniqueID %>" instead of tbUsername in jQuery rules.

    $("#signupForm").validate({
    rules: { 
        "<%=tbUsername.UniqueID %>": {
            required: true,
            minlength: 2
        }, },
    messages: { 
        "<%=tbUsername.UniqueID %>": {
            required: "Please enter a username",
            minlength: "username at least 2 characters"
        }, 
    }.
    

提交回复
热议问题