I'm trying to disable to submit button inorder to avoid duplicate entries.
I have checked all SOF, Google and so.
What happens is, I get the code for disabling the submit button but it doesn't check for whether the form is completed with data or not.
To minimize your time and effort I have the code here is JSFiddle. http://jsfiddle.net/4gL0f2tz/
What I'm trying to do is.
- Check whether the form values are completed (if not throw error - for this I use required attribute)
- Once the form is completed with values then disable the submit button and proceed to process page.
Here is the jQuery snippet
<script type="text/javascript">
$(document).ready(function(){
$('input:submit').click(function(){
$('p').text("Form submiting.....");
$('input:submit').attr("disabled", true);
$.ajax({
type: "POST",
url: "form_process.php",
data: "id=abc" ,
success: function(){alert('success');}
});
});
});
</script>
The full code is available here. http://jsfiddle.net/4gL0f2tz/
Note: I have code to disable the submit button, how can I disable after checking whether all the form values are completed and then disable it.