JQuery验证格式

JQuery验证格式,jquery,error-handling,Jquery,Error Handling,验证单选按钮时,默认错误消息显示在单选按钮和单选按钮文本之间,如下图所示 我想在单选按钮文本后面以红色显示默认错误消息。如何做到这一点? JQuery代码: $(function() { // Setup form validation on the #register-form element $("#myForm").validate({ // Specify the validation rules rules: {

验证单选按钮时,默认错误消息显示在单选按钮和单选按钮文本之间,如下图所示

我想在单选按钮文本后面以红色显示默认错误消息。如何做到这一点?

JQuery代码:

$(function() {

    // Setup form validation on the #register-form element
    $("#myForm").validate({

        // Specify the validation rules
        rules: {
            radio1: "required",
            radio2: "required",
            radio3: "required",
            radio4: "required",
            name: "required",
            datepicker: "required",
            email: {
                required: true,
                //email: true
            },
            email_confirm: {
                required: true,
                //email: true
            },
            phone: {
                required: true,
                //minlength: 10
            }
        },

        // Specify the validation error messages
        messages: {
            firstname: "Please enter your contact name",
            phone: "Please enter your phone",
            email: "Please enter your email",
            email_confirm: "Please re-enter your email to confirm"
        },

        submitHandler: function(form) {
            alert ("Successful");
            //form.submit();
        }
    });

  });

您应该更改html标记,并使用css。请检查errorPlacement属性以进行验证function@NeerajKumar更改html和css是什么意思?JQuery自动生成错误。请检查此链接。您应该在html标记中更改此链接,并对其使用css。请检查errorPlacement属性以进行验证function@NeerajKumar更改html和css是什么意思?JQuery自动生成错误。请检查此链接