Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

match the pattern in the input with javascript

var elem = document.getElementById("Cpostalcode");

var pattern = elem.getAttribute("pattern");
var re = new RegExp(pattern);
if (re.test(elem.value)) {
    // Pattern matches!
} else {
    // Pattern does NOT match.
}
 
PREVIOUS NEXT
Tagged: #match #pattern #input #javascript
ADD COMMENT
Topic
Name
8+6 =