如何验证空文本输入?当输入文本字段为空时,将显示必需的消息。
<script>
function LoadData(data){
var tempdata = data;
var i=0;
while (i<tempdata.activity.length) {
var index = Math.floor(Math.random() * tempdata.activity.length);
qHint[i] = tempdata.activity[i].hint;
i++;
}
}
function hint(data, i){
$('#mypanel' + (i + 1)).append("<label for=text" + (i + 1) + " id=panel"+ (i + 1)+ " style='margin-top:10%;text-align:center;color:white;'><span id=panelTitle"+ (i + 1) +" >"+ data + "</span></label>");// panel item
$('#panel' + (i + 1)).append('<input type="text" name="name" id=text'+ (i + 1) + ' style="text-align: center">');
$('#mypanel' + (i + 1)).append('<a href="#header" data-role="button" name="submit" id=submit'+ (i + 1)+ ' onClick="submitFunc(' +(i+1)+ ')" data-inline="true" data-rel="close" data-icon="check" style="margin-left:75px;">Submit</a>');
$('#mypanel' + (i + 1)).append('<a href=#mypanel'+ (i + 1)+ ' data-role="button" id=cancel'+ (i + 1)+ ' data-inline="true" data-rel="close" data-icon="delete2" style="margin-left:75px;">Cancel</a>');
}
function submitFunc(num){
$("#text"+num).attr("disabled", true);
$("#text"+num).attr("readonly", true);
}
</script>