我们可以在jquery验证插件中调用'required''messages'中的modal吗?

时间:2016-06-10 04:14:15

标签: jquery validation plugins

请帮助。我是新手,如果用户没有在jquery验证插件中上传任何文件,我有一个任务是放置一个模态对话框。我想要'消息'来调用模态,怎么做?有可能吗?

非常感谢你的帮助。

这就是我改变了:

messages:{

'user[image_file_name]': {
                                // required: 'Please browse a file',
                                required: function formSubmit() {
                                    $(#fileUpload).modal("show");
                                },
                                extension: 'File format not supported'
                        },

默认代码是这样的:

$("#smartform").validate({
                errorClass: "state-error",
                validClass: "state-success",
                errorElement: "em"
                rules: {
                    'user[email]': {
                            required: true,
                            email: true,
                    },
                    'user[password]': {
                            required: true
                    },
                    'user[password_confirmation]': {
                            required: true,
                            equalTo: '#password'
                    },
                    'user[phone_number]': {
                            required: true
                    },
                    'user[full_name]': {
                            required: true
                    },
                    'user[street_address]': {
                            required: true
                    },
                    'user[zip_code]': {
                            required: true
                    },
                    'user[province]': {
                            required: true
                    },
                    'user[image_file_name]':  {
                            required: true,
                            extension:"jpg|png|jpeg"
                    },
                },
                messages:{
                    'user[full_name]': {
                            required: 'Please enter Your full name',
                    },
                    'user[street_address]': {
                            required: 'Please enter Your address ',
                    },
                    'user[phone_number]': {
                            required: 'Please enter Mobile Number',
                    },
                    'user[password]': {
                            required: 'Please enter password',
                    },
                    'user[password_confirmation]': {
                            required: 'Please enter password',
                    },
                    'user[zip_code]': {
                            required: 'Please enter zip code',
                    },
                    'user[province]': {
                            required: 'Please enter province',
                    },
                    'user[image_file_name]': {
                            // required: 'Please browse a file',
                            required: function formSubmit() {
                                $(#fileUpload).modal("show");
                            },
                            extension: 'File format not supported'
                    },
                    'user[email]': {
                            required: 'Enter your email address',
                            email: 'Enter a VALID email address'
                    },
                },

0 个答案:

没有答案