PDA

View Full Version : Resolved Form Validation - the most popular question of the century!



crobinson42
10-05-2011, 01:53 AM
hey folks, i'm new js.. i have some forms i'd like to apply this too but realized it doesn't work how i planned. The submit button is disabled until the user enters something in the field. Now if ALL the fields are required, then how can i wait to enable the submit button after ALL the required fields are filled out instead of the submit button being enabled after the first field has something entered into it...



function enableDisableSend(oFld){
oFld.form.send.disabled = (oFld.value == "") ? true : false;
}




<input type="text" name="email" maxlength="50" onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/>
<input type="text" name="temp_password" maxlength="16" onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/>
<input type="radio" name="user_type" value="staff" onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/>
<input type="radio" name="user_type" value="client" onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/>

<input type="submit" name="send" value="Add User" disabled="disabled"/>

rangana
10-05-2011, 09:48 AM
Please apply these changes:


function enableDisableSend(oFld){
document.getElementById('send').disabled = (oFld.value == "") ? true : false;
}


<input type="submit" name="send" id="send" value="Add User" disabled="disabled"/>