I have a <form> Its default property is submitted=false; and I have a statement
function checking() {
var empty = 0;
$('input[type=text]').each(function(){
if (this.value == "") {
empty++;
$("#error").show('slow');
}else{
//missing piece
}
})
So when the user clicks the button and the above statement is not satisfied, I want to add onsubmit="submitted=true;" in my <form> and make it something like this <form onsubmit="submitted=true;".
If I don’t get you wrong, you want to run that check and if it went well you want to set a variable named submitted to TRUE, and set it to FALSE otherwise.
If so, you could do it this way:
If that’s not the case. If you wanted to show an error if there’s an empty field and prevent the form from submitting if there’s an empty field, so you should do it this way: