Skip to content

Instantly share code, notes, and snippets.

Created March 17, 2013 11:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
IE9 form test
<title>Test Form</title>
<script src="form.js"></script>
<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>
'use strict';
window.onload = function () {
console.log('got onload');
var form = document.getElementById('myform');
console.log('form =', form); = 'black'; = 'solid'; = '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