如何检查表单“文本框、复选框、文本区域、选择、文件”中的所有元素是否不为空?
最佳答案
你可以这样看是否有空的:
$(":input").each(function() {
if($(this).val() === "")
alert("Empty Fields!!");
});
You can read on the :input selector here
要获得更具体的答案,如果您只需要这些类型,请像这样更改选择器:
$(":text, :file, :checkbox, select, textarea").each(function() {
if($(this).val() === "")
alert("Empty Fields!!");
});
关于javascript - 如何检查表单元素是否为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2469999/