Last active
September 5, 2016 13:31
-
-
Save ekashida/7e93b1ea6ff229d972f2e11cd54d480f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<h1>ValidityState.patternMismatch test</h1> | |
<h2>input.pattern: "/foo/"</h2> | |
<input id=with-input value=foo pattern="/foo/" disabled /> | |
<div id=with-output></div> | |
<h2>input.pattern: "foo"</h2> | |
<input id=without-input value=foo pattern="foo" disabled /> | |
<div id=without-output></div> | |
<script id="jsbin-javascript"> | |
var withOutput = document.querySelector('#with-output') | |
var withInput = document.querySelector('#with-input') | |
var withoutOutput = document.querySelector('#without-output') | |
var withoutInput = document.querySelector('#without-input') | |
withOutput.innerHTML = [ | |
'<ul>', | |
'<li>input.validity.valid: ' + withInput.validity.valid + '</li>', | |
'<li>patternMismatch property: ' + withInput.validity.patternMismatch + '</li>', | |
'<li>patternMismatch computed: ' + !(new RegExp(withInput.pattern).test(withInput.value)) + '</li>', | |
'</ul>' | |
].join('') | |
withoutOutput.innerHTML = [ | |
'<ul>', | |
'<li>input.validity.valid: ' + withoutInput.validity.valid + '</li>', | |
'<li>patternMismatch property: ' + withoutInput.validity.patternMismatch + '</li>', | |
'<li>patternMismatch computed: ' + !(new RegExp(withoutInput.pattern).test(withoutInput.value)) + '</li>', | |
'</ul>' | |
].join('') | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var withOutput = document.querySelector('#with-output') | |
var withInput = document.querySelector('#with-input') | |
var withoutOutput = document.querySelector('#without-output') | |
var withoutInput = document.querySelector('#without-input') | |
withOutput.innerHTML = [ | |
'<ul>', | |
'<li>input.validity.valid: ' + withInput.validity.valid + '</li>', | |
'<li>patternMismatch property: ' + withInput.validity.patternMismatch + '</li>', | |
'<li>patternMismatch computed: ' + !(new RegExp(withInput.pattern).test(withInput.value)) + '</li>', | |
'</ul>' | |
].join('') | |
withoutOutput.innerHTML = [ | |
'<ul>', | |
'<li>input.validity.valid: ' + withoutInput.validity.valid + '</li>', | |
'<li>patternMismatch property: ' + withoutInput.validity.patternMismatch + '</li>', | |
'<li>patternMismatch computed: ' + !(new RegExp(withoutInput.pattern).test(withoutInput.value)) + '</li>', | |
'</ul>' | |
].join('')</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var withOutput = document.querySelector('#with-output') | |
var withInput = document.querySelector('#with-input') | |
var withoutOutput = document.querySelector('#without-output') | |
var withoutInput = document.querySelector('#without-input') | |
withOutput.innerHTML = [ | |
'<ul>', | |
'<li>input.validity.valid: ' + withInput.validity.valid + '</li>', | |
'<li>patternMismatch property: ' + withInput.validity.patternMismatch + '</li>', | |
'<li>patternMismatch computed: ' + !(new RegExp(withInput.pattern).test(withInput.value)) + '</li>', | |
'</ul>' | |
].join('') | |
withoutOutput.innerHTML = [ | |
'<ul>', | |
'<li>input.validity.valid: ' + withoutInput.validity.valid + '</li>', | |
'<li>patternMismatch property: ' + withoutInput.validity.patternMismatch + '</li>', | |
'<li>patternMismatch computed: ' + !(new RegExp(withoutInput.pattern).test(withoutInput.value)) + '</li>', | |
'</ul>' | |
].join('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment