Categories:
Partners

Creating user friendly and self-guiding forms

The disabled attribute, along with JavaScript, can be used to create highly user friendly and self-guiding forms. For example, you can temporarily disable the submit button of a form until all the required elements have been filled in by the user, or a form that disables/ enables different form elements, depending on the path the user chooses. I'll end this tutorial with a simple example- it's up to you to go and create the real thing (ok, I'm just tired and need some rest)!

The below form will only allow you to submit if the textbox is filled in:

<script type="text/javascript">
function checkifempty(){
if (document.aform.contentarea.value=='')
document.aform.button.disabled=true
else
document.aform.button.disabled=false
}
if (document.all || document.getElementById)
setInterval("checkifempty()",100)
</script>
Copyright 1997-2014 JavaScript Kit. NO PART may be reproduced without author's permission.