I have written a little script that enables the submit button when the user changes the data in a form. There are lots of fields over lots of pages, is there a way in javascript to target every form element so I don't have to put onchange='enableSubmit()' onto every field?
Here's what I have
Here's what I have
Code:
<!DOCTYPE html>
<html xmlns='[URL unfurl="true"]http://www.w3.org/1999/xhtml'[/URL] xml:lang='en'>
<head>
<meta http-equiv='content-type' content='text/html; charset=UTF-8'>
<title>Colour submit button</title>
<style>
.grey {background-color: grey}
.blue {background-color: blue}
</style>
<script type='text/javascript'>
function enableSubmit() {
//document.getElementById("submitButton").setAttribute("class", "blue");
document.getElementById('submitButton').disabled="";
}
</script>
</head>
<body>
<form action=''>
<input type='text' name='foo' onchange='enableSubmit()' />
<select name='footwo' onchange='enableSubmit()'>
<option>Something</option>
<option>Something</option>
</select>
<input type='submit' id='submitButton' disabled='disabled' />
</form>
</body>
</html>