Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在以下代码中添加另一个不接受的条件';0';_Javascript - Fatal编程技术网

Javascript 在以下代码中添加另一个不接受的条件';0';

Javascript 在以下代码中添加另一个不接受的条件';0';,javascript,Javascript,我编写了以下javascript代码,现在我想添加另一个条件/更改不接受零的现有条件 if ( !onlyNumbers($(".vo_head_spots_available:eq(" + i + ")").val())&& $(".vo_head_spots_available:eq(" + i + ")").val().toUpperCase()!="U") { $('#msg_f').html('Plea

我编写了以下javascript代码,现在我想添加另一个条件/更改不接受零的现有条件

  if ( !onlyNumbers($(".vo_head_spots_available:eq(" + i + ")").val())&& $(".vo_head_spots_available:eq(" + i + ")").val().toUpperCase()!="U")
             {
                   $('#msg_f').html('Please enter the # spots available for your Participants. If unlimited, enter U.').show();
                   $(".vo_head_spots_available:eq(" + i + ")").css('background-color', '#fdd');
                                                        isValid = false;
             }
      else
             {
                  $(".vo_head_spots_available:eq(" + i + ")").val($(".vo_head_spots_available:eq(" + i + ")").val().toUpperCase());
                  $('#msg_f').html('').hide();
                  $(".vo_head_spots_available:eq(" + i + ")").css('background', '');
             }
或许

var spots = $(".vo_head_spots_available:eq(" + i + ")");
var val = spots.val.toUpperCase();

if (val =="U" || (onlyNumbers(val) && val !=0)) {
  $('#msg_f').html('').hide();
  spots.css('background', '');
}
else {    
  $('#msg_f').html('Please enter the # spots available for your Participants. If unlimited, enter U.').show();
  spots.css('background-color', '#fdd');
  isValid = false;
}
甚至

var spots = $(".vo_head_spots_available:eq(" + i + ")");
var val = spots.val.toUpperCase();
var isValid = val =="U" || (onlyNumbers(val) && val !=0);
if(isvalid) {
  $('#msg_f').html('').hide();
  spots.css('background', '');
}
else {    
  $('#msg_f').html('Please enter the # spots available for your Participants. If unlimited, enter U.').show();
  spots.css('background-color', '#fdd');
}

我们怎么能帮你呢?改变什么条件?你需要更具体一点。
var val = $(".vo_head_spots_available:eq(" + i + ")").val();

if(0 != val && "U" != val.toUpperCase() && !onlyNumbers(val)) {
    // ...
} else {
    // ...
}