We are using a native HTML5 validation API, which internally uses pattern matching to check whether what we are typing is conformant to certain rules.
Consider the attribute required in the following line:
<input type="text" required>
This ensures that when we submit the form, the field is actually populated, while having type="email" in the other input element ensures that the content resembles an e-mail format.
This API is very rich and you can read more at https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation.
Many a times, the problem is that to leverage this API, we need to trigger the native validation mechanism. This means that we are not allowed to prevent the default behavior of the ...