My pattern currently allows letters and does not allow spaces and numbers, intentionally. However, I would like to allow characters such as !@#$%^&*()_+=-[]|}{;’":,./?>< for my pattern and input type. How would I doe this?
I tried searching all over the internet and found lots of solutions but none of them worked for me.
Here is my code:
<html>
<body>
<form method="get">
<input type="number" min="0" max="150" name="Age"/>
<input type="text" name="Name" pattern="[A-Za-z]+"/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
3
Answers
[^s]
matches any character that is NOT a whitespace character.You can do it, but have in mind that source code in html is manipulable, so consider validate it in server side
Service Side
Try:
Explanation:
Any amount of characters
[
…]+
that is not^
a numberd
or whitespaces
.Examples:
RegEx101