When jquery submits elements whose value is not empty,
can be used for querying using
specific code :
//When executing the query, if the form field is empty, it will not be submitted
$("#form1").submit(function (){
try {
$(this).find("*").each(function(){
var elem = $(this);
if (elem.prop(" name") != null&&elem.prop("name") != "") {
if(elem.val()==""){
elem.removeAttr("name");
}
}
});
}catch(e){
alert(e);
}
return true;
});
Note that only one should be returned. The submit method of the form takes a bool value. If it does not return one by default, it will be void
Principle: When the form is submitted, it is based on the name attribute of the element. Yes, as long as the name attribute is not added, it will not be submitted.
The first step is to find all elements, that is, *, and then determine whether the name attribute is not null or empty.
After getting the element, then remove the name attribute if the value is empty.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn