pattern Attribute
The pattern attribute used a pattern to validate an input field.The pattern is a regular expression.
Note: The pattern attribute works with the following <input> types: text, search, url, telephone, email, and password.
The example below shows a text field that can only contain three letters (no numbers or special characters):
Syntax
Country code: <input type="text" name="country_code"
pattern="[A-z]{3}" title="Three letter country code" />
pattern="[A-z]{3}" title="Three letter country code" />
Example
<!DOCTYPE html><html>
<body>
<form action="demo_form.asp" method="get">
Country code: <input type="text" name="country_code" pattern="[A-z]{3}"
title="Three letter country code" />
<input type="submit" />
</form>
</body>
</html>
No comments:
Post a Comment