Ensuring a Value Matches a Pattern
Description
The pattern
attribute ensures that a value matches a regular expression.
Example
The following code shows the pattern attribute in use.
<!DOCTYPE HTML>
<html>
<body>
<form method="post" action="http://example.com/form">
<p>
<label for="name"> Name: <input type="text" id="name"
name="name" pattern="^.* .*$" />
</label>
</p><!-- w ww. j ava2s . co m-->
</form>
</body>
</html>
Note
The pattern ensures that the user enters two names, separated by a space.