input required - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:input

Introduction

You do this with the required attribute.

The user cannot submit the form until a value has been provided.

Using the required Attribute

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <form method="post" action="http://example.com/form"> 
         <input type="hidden" name="recordID" value="1234"> 
         <p> 
            <label for="name">
                Name: <!--from w  w w  .  j  a  va2s  .  c  o  m-->
               <input type="text" required id="name" name="name"> 
            </label> 
         </p> 
         <p> 
            <label for="password">
                Password: 
               <input type="password" required placeholder="Min 6 characters" id="password" name="password"> 
            </label> 
         </p> 
         <p> 
            <label for="accept"> 
               <input type="checkbox" required id="accept" name="accept">
                Accept Terms &amp; Conditions 
            </label> 
         </p> 
         <input type="submit" value="Submit"> 
      </form>  
   </body>
</html>

Related Tutorials