0

I have used regular expression pattern with input type 'email' which is supposed to support ASCII as well as Unicode characters.

But when I try to submit it shows 'Please match the requested format' even for ASCII email address.

Code as follows :

<!DOCTYPE html>
<html>
<body>

<form>
  <label for="email">Email:</label>
  <input type="email" id="email" name="email" pattern="/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i">
  <input type="submit">
</form>

</body>
</html>

Why this is happening. Any information on that would be greatly appreciated.

Thank you.

Stack User
  • 19
  • 1
  • 5
  • 1
    It is not possible to answer your question, you have to provide more information, such as the regular expression you use. – mad-hin Nov 01 '21 at 14:33
  • @mad-hin Edited the question. Kindly have a look. – Stack User Nov 01 '21 at 15:38
  • If you’re passing your pattern as a string, it’s not clear why you would prepend/append `/` delimiters as you would only with a JavaScript RegExp literal - can you elaborate on why exactly you have elected to do so? Have you read the MDN page on [the `pattern` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern)…? – esqew Nov 01 '21 at 15:40
  • Tried removing the slashes. Still in the same phase. – Stack User Nov 01 '21 at 16:26
  • You should post the code that's processing the page. What you've shown, the page, is insufficient to explain the code that's responding with: "Please match the requested format". And you'll want to tag the question with "regex" and whatever language that is executing the aforementioned code. Along with the code, you'll want to adding debugging code that will emit the regex and email address it received. – Jeff Holt Nov 01 '21 at 16:54
  • Wrong `[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]`? I'd try [_Unicode Categories_](https://www.regular-expressions.info/unicode.html) instead e.g. something like `[\p{L}|\p{N}]` for a letter _or number_… – JosefZ Nov 01 '21 at 16:56
  • Is there any difference between regular expression mentioned as a part of JavaScript and the one used with HTML pattern attribute. – Stack User Nov 05 '21 at 12:55

0 Answers0