How to add a regular expression that an <input> element's value is checked against in HTML?

HTMLWeb DevelopmentFront End Technology

Use the pattern attribute to set the regular expression that an <input> element’s value is checked. You can try to run the following code to implement pattern attribute −


<!DOCTYPE html>
      <title>HTML novalidate attribute</title>
      <form action = "" method = "get" novalidate>
         Student Name<br><input type = "name" name = "sname"><br>
         Rank<br><input type = "number" name = "rank"><br>
         Student Country <br><input type = "text" name = "ccode" pattern="[A-Za-z]{3}" title = "country code"><br>

         <input type = "submit" value = "Submit">
Published on 14-Mar-2018 14:38:39