Jimbo wrote:
I am trying to right a script so that the "submit button" only appears
when certain criteria has been met. I have tried putting it in an IF
statement, without any luck. Maybe a function would allow me to do this?
<input type="Submit" value="Update">
Any help would be greatly appreciated
TIA
Jim
You definatly want JavaScript here. Even though this is a PHP group, I'll
give you the JS for free
<form name="inputform">
<input type="text" name="field1" value="" onblur="javascript
:validate();" />
<input type="text" name="field2" value="" onblur="javascript
:validate();" />
<input type="submit" name="submit" value="Submit" disabled
onclick="javascript
:disable();" />
</form>
<script language="JavaScript">
function validate(){
if(document.inputform.field1.value != ""){
if(document.inputform.field2.value != ""){
document.inputform.submit.disabled = false;
}
}
}
function disable(){
document.inputform.submit.disabled = true;
document.inputform.submit.value = "Please wait... Form is being
submitted.";
}
</script>
Obviously you will have to edit your form/javascript validation for your
page, but this is the basic idea of what you need to do. With this, it
will be impossible for the user to push the submit button until everything
is validated. It will also disable the submit button after the user clicks
it to prevent double submitting by impatient users.