最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Check jquery unobtrusive validation is true by jQuery - Stack Overflow

programmeradmin4浏览0评论

I use MVC 3 Model Validation Attributes and jquery unobtrusive to show validation error message also use the script when form submitted return a confirm. So I need to check if the all fields are valid then return Confirm: some thing like the following pseudo-script:

$('div.FormNeedConfirm form').submit(function () {
    if ($(this).validate() == true) {
        var Message = $('#FormConfirmMessage').val();
        return confirm(Message);
    }
});

But I don't know what exactly should be in the if condition. What is your suggestion?

I use MVC 3 Model Validation Attributes and jquery unobtrusive to show validation error message also use the script when form submitted return a confirm. So I need to check if the all fields are valid then return Confirm: some thing like the following pseudo-script:

$('div.FormNeedConfirm form').submit(function () {
    if ($(this).validate() == true) {
        var Message = $('#FormConfirmMessage').val();
        return confirm(Message);
    }
});

But I don't know what exactly should be in the if condition. What is your suggestion?

Share Improve this question edited Nov 26, 2014 at 14:50 Mark 3,1234 gold badges23 silver badges31 bronze badges asked May 3, 2012 at 8:19 SaeidSaeid 13.6k34 gold badges109 silver badges177 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 20
if ($(this).valid()) {

    var Message = $('#FormConfirmMessage').val();
    return confirm(Message);
}

if ($(this).validate() = true) // your if condition should be "==". change to like this

if ($(this).validate() == true) 
发布评论

评论列表(0)

  1. 暂无评论