jQuery Validation plugin in ASP.NET Web Forms

后端 未结 11 2107
被撕碎了的回忆
被撕碎了的回忆 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:06

    Tested what Darin Dimitrov said and it works perfectly, but if you don't want to set a specific class to each of your fields, you can use jQuery selectors:

    $('form').validate();
    $('input[id$=Username]').rules('add', { 
        required: true, 
        messages: { 
            required: 'Some custom message for the username required field' 
        } 
    });
    
    
    

提交回复
热议问题