function setup() {
	if(document.createElement('input').validity) {
		var theForm = document.theForm;
		var inputArr = theForm.querySelectorAll('input:not([type="submit"])');
		for(var i = 0; i < inputArr.length; i++) {
			inputArr[i].addEventListener('input', validate, false);
			inputArr[i].addEventListener('blur', validate, false);
		}
	}
}

function validate(e) {
	var t = e.target;
	var check = t.validity;
	var alertStr = '';
	if(check.valueMissing) {
		alertStr = '入力必須項目です。';
	} else {
		if(check.patternMismatch) {
			alertStr = '入力内容が正しくありません。';
		}
	}
	var alertElement = t.parentNode.querySelector('span');
	alertElement.innerHTML = alertStr;
}