jQuery UI Dialog validation without using <form> tags

前端 未结 11 1756
北荒
北荒 2020-12-23 20:40

http://bassistance.de/jquery-plugins/jquery-plugin-validation/ looks to be the best jquery validation plugin out there. I can\'t seem to get it working in the jQuery UI dial

11条回答
  •  旧巷少年郎
    2020-12-23 21:20

    You can use the valitidy jquery plugin

    The javascript

    function validateForm(){  
        $.validity.start();   
        // Required:  
        $("#recipientFirstName").require();  
        var result = $.validity.end();  
        return result.valid;  
    }
    
    $(document).ready(function() { 
        $('#dialog').dialog({
            autoOpen: false,   
            title: 'My title', 
            width: 600,  
            modal: true,  
            buttons: {  
                "Ok": function() {   
                    if(validateForm()) {
                        saveOrder();
                        $(".validity-tooltip").css("display", "none"); 
                        $(this).dialog("close");  
                    }
                },
                "Cancel": function() {
                    // The following line was added to
                    // hide the tool-tips programmatically:          
                    $(".validity-tooltip").css("display", "none");
                    $(this).dialog("close");       
                }
            }
       });
    })
    

提交回复
热议问题