如何检查此变量是否包含使用parseInt转换的空输入字段?我必须将输入val存储到变量中,我需要使用parseInt。请帮忙。
var myinput = parseInt ($('input#day').val());
if (myinput.length < 1){
$('<p>Empty field</p>').appendTo('#mydiv');
}
答案 0 :(得分:0)
尝试以这种方式检查,因为您正在使用jQuery:
var input = $(this);
// This suffices
if (!input.val()) {
// Empty
$('#mydiv').append(input)
}
// However, if you insist on the use of parseInt, then try this
if (!parseInt(input.val())) {
// Empty
$('#mydiv').append(input)
}
&#13;