I have a form as shown below in which I want the user to enter the url in the input box starting from http:// or https:// with one period to be present after subdomain. If the user doesn't do so it should say "Please match the requested format".
This is what I have tried. The following code takes only from https not http.
<label for="url">Enter an https:// URL:</label>
<input type="url" name="url" id="url" placeholder="https://example.com" pattern="https://.*" size="30" required> <!-- Line A -->
The pattern which I want is:
In the first 2 cases, user doesn't type www in the input box and in the last 2 cases user types www In the above four urls, it has atleast one period after subdomain and it starts from http or https.
In short, I want the following 2 requirements to be met when user enters the url in the input box.
- It should start from http or https.
- It should have at-least one period after sub-domain.
Problem Statement:
I am wondering what changes I should make in the pattern above at Line A so that it meets my requirements.
pattern="https://.*"but I am not sure what it should be.