javascript - Validate Multiple Email Addresses with HTML5 -
i'm trying construct email form takes multiple comma separated emails input , verifies them using html5. want use following regex sanity check input:
\b[a-za-z0-9._%+-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}\b here's i've tried
this doesn't seem work more one:
<input type="email" pattern="\b[a-za-z0-9._%+-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}\b" value="" multiple> this works, built in email validation, seems .+@.+.
<input type="email" value="" multiple> is there way mix pattern , multiple regex checks each item in comma separated list?
i have demo here: http://codepen.io/ben336/pen/ihjka
try this:
<input type="email" multiple pattern="^([\w+-.%]+@[\w-.]+\.[a-za-z]{2,4},*[\w]*)+$" value=""> update:
using <input type="email" value="" multiple> seem bugged letting "a@b" pass. though go method keep semantics said, , use validation on server side in case tries submit email "a@b".
just note, should validate on server side security reasons anyway, client side validation can bypassed easily.
Comments
Post a Comment