0

I have a input url and pattern set to "^http://" as simplest pattern. When I use the value as below it says as patternMismatch in validity object. What is wrong with the pattern or value

<input value="http://www.example.com" pattern="^http://" type="url"/>, 
ams
  • 91
  • 7

1 Answers1

0

You need to escape your backslashes. Also, start and end anchoring is implicit:

<input value="http://www.example.com" pattern="http:\/\/.+" type="url"/>

The .+ ending means that there must be at least one character. Basically, this RegExp is actually:

/^http:\/\/.+$/u

The u flag and ^ and $ anchors are implicit:

wilsonzlin
  • 2,154
  • 1
  • 12
  • 22