好吧所以我试图检查这些字段是否只是空白(输入了空格或没有信息)但是如果我只是在它们内部按空格几次它根本不会检测到它们是空的,它只会处理它通常
$("form.ajax_call").submit(function(e) {
var name = $.trim($('#project_name').val()),
price = $.trim($('#value_change').val()),
description = $.trim($('#project_description').val());
if (name === '') {
alert("Please enter the project name");
e.preventDefault();
return false;
}
if (price === '') {
alert("Please enter the project price");
e.preventDefault();
return false;
}
if (description === '') {
alert("Please enter the project description");
e.preventDefault();
return false;
}
});