<input type="text" pattern="[-0-9]+" required error-empty="please enter the date you want to attend the performance on" />
http://www.broken-links.com/tests/html5forms/
function hasValidation() {
return 'noValidate' in document.createElement('form');
}
function formCheckVal() {
var formValidity = document.forms[0].checkValidity();
(formValidity === true ) ? window.alert('This form will validate') : window.alert('This form will not validate');
}
function inputCheckVal(inputId) {
var inputValidity = document.getElementById(inputId).checkValidity();
if (inputValidity === true ) {
window.alert('This input will validate');
} else {
var validityStatus = document.getElementById(inputId).validity;
var validityString = '';
for (prop in validityStatus) {
if(validityStatus[prop] === true) {
window.alert('This input will not validate because: ' + prop);
}
}
//window.alert(validityStatus);
}
}
window.onload = function() {
var doesItValidate = hasValidation();
if (doesItValidate === true) {
// Check validity of form
document.getElementById('form_checkval').addEventListener('click',formCheckVal,true);
// Check validity of inputs
var inputLabels = document.querySelectorAll('label');
var labelCount = inputLabels.length;
for (i=0;i<labelCount;i++) {
inputLabels[i].addEventListener('click',function(){
var labelFor = this.getAttribute('for');
inputCheckVal(labelFor);
},false);
}
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.