你可以使用这个代码,来找到这个时机
- $('input[othertext="otherText"]')
- .focusout(function(event) {
- var target = event.target;
- if (typeof (target.value) === 'undefined' || target.value === '') {
-
- var labels = $(target).siblings('label');
- var otherCheck = labels[labels.length - 1];
- var isChekced = $(otherCheck).find('input')[0].checked;
- if (isChekced) {
- alert('该值不能为空');
- }
- }
- });
-
- function checkEmptyOtherText() {
- var checkboxes = $('input[othercheck="otherCheck"]');
- for(var i = 0; i < checkboxes.length; i++) {
- var checkbox = checkboxes[i];
- if (checkbox.checked) {
- var textInput = $(checkbox).parent().siblings(':last');
- if (textInput.val() == '') {
- alert('有空值');
- }
- }
- }
- }
复制代码 |