Skip to content

Instantly share code, notes, and snippets.

@zaimramlan
Last active September 20, 2016 08:46
Show Gist options
  • Save zaimramlan/aa11a23888c999d70f5fbc5a27ca6f7d to your computer and use it in GitHub Desktop.
Save zaimramlan/aa11a23888c999d70f5fbc5a27ca6f7d to your computer and use it in GitHub Desktop.
Form Validation with HTML 5
<input type=[TYPE] pattern=[REGULAR_EXPRESSION] title=[HINT]>

Value(s) for REGULAR_EXPRESSION

^\d{4}-\d{3}-\d{4}$: For telephone numbers. (i.e. 0000-000-0000)

[a-zA-Z0-9]+: For alphanumeric values.

^@[A-Za-z0-9_]{1,15}$: For twitter usernames. (i.e. @tweet_handle, up to 15 characters)

Hints

title attribute: Can give hints to user on accepted input pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment