1
var student_office_id = $(this).data('office');
,我期待用它在jQuery的驗證插件,像這樣:
$('.office_directed_to, .degree_type').bind('change', function() {
var student_office_id = $(this).data('office');
$("#admin-form").validate({
rules: {
"h_number["+student_office_id+"]": {
required: function(element) {
return $("#office_directed_to-8").val() != '';
}
},
"degree_type["+student_office_id+"]": {
required: function(element) {
return $("#office_directed_to-"+student_office_id+).val() != '';
}
}
} // end rules
}); // end validate
}); // end bing change
我收到以下錯誤的控制檯:未捕獲SyntaxError:意外標識符
它引用我嘗試附加student_office_id的第一行,我想它會在其他實例上返回一個錯誤。
你可以粘貼'console.log(student_office_id)'的結果嗎? – Florent 2012-08-06 15:42:37