Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用此代码要求用户在一组字段中输入至少一个值。但如果用户在所有字段中均未输入任何内容,则会为所有空字段显示错误消息。我怎样才能只为一个字段显示它?还是分开?我试图使用errorContainer 选项,但它会影响其他字段。
也许是围绕所有元素的循环。找到那个空的。
$('form input').each(function(){ if ($(this).val() == ""){ //do code } });
那应该行得通。试试看。:)