How can I check if an input field value is in a specific shape like This : String@string.string
without using the input type email.
How can I check if an input field value is in a specific shape like This : String@string.string
without using the input type email.
using patterns:
<input type="text" pattern="some_regex"/>
in your case:
<input type="text" pattern="[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]+"/>
or just
<input type="text" pattern="\S+@\S+\.\S+"/>
if you want to use javascript, you can use:
function validateInput(){
const regex = /some_regex/
return regex.test(inputElement.value)
}
// example
function validateInput(){
const regex = /\S+@\S+\.\S+/
return regex.test(inputElement.value)
}