Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mvolkmann
Created March 17, 2013 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvolkmann/5181215 to your computer and use it in GitHub Desktop.
Save mvolkmann/5181215 to your computer and use it in GitHub Desktop.
IE9 form test
<html>
<head>
<title>Test Form</title>
<script src="form.js"></script>
</head>
<body>
<form id="myform" method="post" action="http://localhost:3000">
<label for="name">Name:</label>
<input id="name" name="name" type="text"/>
<button type="submit">Go!</button>
</form>
</body>
</html>
'use strict';
window.onload = function () {
console.log('got onload');
var form = document.getElementById('myform');
console.log('form =', form);
form.style.borderColor = 'black';
form.style.borderStyle = 'solid';
form.style.borderWidth = '3px';
console.log('form.addEventListener =', form.addEventListener);
var name = document.getElementById('name');
var listener = function (event) {
console.log('name = "' + name.value + '"');
console.log('name.length =', name.length);
if (name.value.length === 0) event.preventDefault();
//if (name.value.length === 0) return false; // works everywhere but IE (tes
ted IE9)
};
form.addEventListener('submit', listener);
//form.onsubmit = listener;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment