简体   繁体   中英

HTML5 input secure ssl

I have an input tag like:

<input type="url" id="inputWebsite" name="url">

I need to ensure that the value the user enters contains a secure url like https:// How can I do it ?

你可以尝试使用这个:

<input type="url" name="website" id="inputWebsite" required pattern="https://.+">

You can use pattern in html5 url tag:

<input type="url" pattern="https?://.+" required />

In the papper Uniform Resource Identifier (URI): Generic Syntax [RFC3986] http://www.ietf.org/rfc/rfc3986.txt the regular expression for a URI is:

^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?

For example, matching the above expression to

  http://www.ics.uci.edu/pub/ietf/uri/#Related

results in the following subexpression matches:

  $1 = http:
  $2 = http
  $3 = //www.ics.uci.edu
  $4 = www.ics.uci.edu
  $5 = /pub/ietf/uri/
  $6 = <undefined>
  $7 = <undefined>
  $8 = #Related
  $9 = Related

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM