jQuery Validation - Two fields, only required to fill in one

前端 未结 7 1870
醉梦人生
醉梦人生 2020-11-30 01:20

I\'m using the jQuery Validation Plugin on my form. On my form I have a \'Telephone\' field and a \'Mobile No.\' field.

How would I go about making it so the user ha

7条回答
  •  渐次进展
    2020-11-30 01:37

    This Will do

    Mobile: {
        required: function(element) {
        return (jQuery.isEmptyObject($("#Phone").val()));
        }
    },
    Phone: {
        required: function(element) {
            return (jQuery.isEmptyObject($("#Mobile").val()));
        }
    }
    

提交回复
热议问题