HTML <input> Tag with the 'pattern' Attribute

<form name="myForm" action="https://www.PuStudy.Com/resources/html-forms-action.html" target="_blank">
	
<input name="myInput" pattern="\w{5}" title="Enter 5 characters">

<button>Submit</button>

</form>

The above example demonstrates usage of the <input> element with the pattern attribute.

The pattern attribute can be used to validate the form contents when the user attempts to submit the form. It allows you to provide a JavaScript regular expression that will be used to check that the form control's value is in the correct format. Using the pattern attribute, you can specify the exact pattern that is required.

In the above example, the user must enter 5 characters into the text input field. The \w{5} value is a regular expression that stipulates this rule.