我在这里有一个 jsfiddle http://jsfiddle.net/cbyJD/74
我遇到的问题是它没有在警报中显示问题编号,而是显示 NaN。此外,即使所有文本输入都已填写,它仍会显示一条警报,说明我有一个空的文本输入。
我在小提琴中做错了什么?
Jquery 验证()函数在这里:
function validation() {
var alertValidation = "";
var _qid = "";
var _msg = "";
$("[class*='q']").each(function(i) {
var questions = parseInt($("[class*=q" + i + "_qnum]").text());
var marks = parseInt($("[class*=q" + i + "_ans_text]").text());
var txtinput = $("[class*=q" + i + "_mark]").val();
_qid = questions;
_msg = "You have errors on Question Number: " + _qid + "\n";
if (txtinput == '' || txtinput == null) {
alertValidation += "\n\u2022 You have not entered in a value for all the Indivdiaul Marks textbox\n";
}
if (alertValidation != "") {
return false; //Stop the each loop
}
});
if (alertValidation != "") {
alert(_msg + alertValidation);
return false;
}
return true;
}