How can I disable the submit button with JAVA Script untill all the mandatory fieleds are filled? if any body can help.. its urgent please

How can I disable the submit button with JAVA Script untill all the mandatory fieleds are filled? if any body can help.. its urgent please

Keep "Submit Button" Disbaled by default.

Then on each mandatory field put

onBlur="function();"

in this function write the code to check all the mandatory fileds are filled, if yes then enable your submit button or no keep disabled.

Call the same "function();" on each filed blur.

I hope this is clear.

Cheers...

You could try to write a function that will check each field for correctness and then use the form id to submit it with javascript. Instead of having a submit input use a button instead that onclick calls the function.

<script type="text/javascript">
function checkThenSubmitForm()
{
<!-- form checking instructions -->;
document.getElementById('theForm').submit();
return true;
}
</script>
<form id="theForm" action="whatever.php" method="post">
<!-- THE INPUT FIELDS -->
<input type="button" value="Submit" onclick="checkThenSubmitForm()">

I think thats right, but the idea is there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.