Page 151 - CITS - Computer Software Application -TT
P. 151

COMPUTER SOFTWARE APPLICATION - CITS




                       <meta name=”viewport” content=”width=device-width, initial-scale=1.0” />
                       <link rel=”stylesheet” href=”css/style.css” />
               </head>
               <body>

                       <div class=”container”>
                              <form action=”signup.html” method=”post” id=”signup”>
                                     <h1>Sign Up</h1>
                                     <div class=”field”>
                                            <label for=”name”>Name:</label>
                                            <input  type=”text”  id=”name”  name=”name”  placeholder=”Enter  your
           fullname” />
                                            <small></small>
                                     </div>
                                     <div class=”field”>
                                            <label for=”email”>Email:</label>

                                            <input type=”text” id=”email” name=”email” placeholder=”Enter your email
           address” />
                                            <small></small>
                                     </div>
                                     <div class=”field”>

                                            <button type=”submit” class=”full”>Subscribe</button>
                                     </div>
                              </form>
                       </div>
                       <script src=”js/app.js”></script>
               </body>
           </html>
           Code language: HTML, XML (xml)

           The HTML document references the style.css and app.js files. It uses the <small> element to display an error
           message in case the <input> element has invalid data.
           Submitting the form without providing any information will result in the following error:
           :
           The following shows the complete app.js file:

           // show a message with a type of the input
           function showMessage(input, message, type) {
               // get the small element and set the message
               const msg = input.parentNode.querySelector(“small”);
               msg.innerText = message;
               // update the class for the input

               input.className = type ? “success” : “error”;
               return type;



                                                           138

                             CITS : IT&ITES - Computer  Software Application - Lesson 37 - 46
   146   147   148   149   150   151   152   153   154   155   156