Though field validation and data formatting are the biggest challenges of working with web browsers, HTML5 does some help in enforcing this for us. Telephone input field can be created using type=”tel”: <input type="tel" name="phone_num" id="phone_num"/> This looks like every other input field, with the difference that it optimizes the keyboard. Certain platforms like tablets, or smartphones will pop-up only-numeric keyboard for this input field. It is hard to enforce particular regular expression through HTML because of variety of phone number formats used along with differences in country codes, and number separators.
Suppose you have a checkbox in your HTML form like this: <form> Email Address: <input type="email" name="email"> <input type="checkbox" name="opt_in_newsletter" > Subscribe to the newsletter </input> If the user checks the option, you will get the following form data firstname.lastname@example.org opt_in_newsletter=on However, if the user does not check the option, then the opt_in_newsletter field itself will not be present in the form data that you receive on the server-side.