Before submitting any data, it is important to ensure all required fields are filled out and in the correct format. You can do that using HTML form validation attributes.

Learn more about form validations on the Mozilla developer page.

Common examples:

Required filed

<input type="text" name="name" **required**>

Minimum or Maximum length validation

<input type="text" name="message" **minlength="5"**>
<input type="text" name="message" **maxlength="50"**>

E-Mail validation

<input **type="email"** name="email">

Number validation

<input **type="number"** name="amount" **min="1" max="10"**>

Pattern validation

The pattern attribute specifies a regular expression the form control's value should match.

<label>Enter your phone number in the format (123)456-7890 
  (<input name="tel1" type="tel" **pattern="[0-9]{3}"** size="2"/>)-
   <input name="tel2" type="tel" **pattern="[0-9]{3}"** size="2"/> - 
   <input name="tel3" type="tel" **pattern="[0-9]{4}"** size="3"/>