function validateForm() {
            return $("#mainForm").validate({
                errorElement: "em",
                rules: {
                    name: {
                        required: true,
                        remote: {
                            type: "POST",
                            url: "/plant/check",
                            data: {
                                pname: function() { return $("#name").val(); },
                                pid: function() { return $("#id").val(); }
                            }
                        }
                    },
                    design_power:
                    {
                        required: true,
                        number: true
                    }
                },
                messages: {

                    name: {
                        required: '',
                        remote: ""

                    },
                    longitude: {
                        number: '',
                        max: '',
                        min: ''
                    },
                    latitude: {
                        number: '',
                        max: '',
                        min: ''
                    },
                    design_power: {
                        required: "",
                        number: ''
                    },
                    email: {
                        email: ""
                    }
                },
                errorPlacement: function(error, element) {
                    parent.iframeauto();
                    if (document.getElementById("error_" + element.attr("name"))) {
                        error.appendTo("#error_" + element.attr("name"));
                    }
                    else
                        error.insertAfter(element);

                },
                success: function(em) {

                }
            }).form();
           
        }

 

    //执行提交表单  体检之前先验证填写是否正确
        function execute(issubmit) {
            if (validateForm() && issubmit)
                document.forms[0].submit();
            return validateForm();
        }

 转载请注明:http://www.liebo6.com