Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 118 - CodePilot V5.0 C8
P. 118

    Ask
                                                                           AGENT
                                                            OrangeAI
                        Design a login form in HTML with Username and Password fields and use JavaScript to display an alert if
                        any field is left empty when the user clicks the Login button.

                               Study

                             SOME MORE PROGRAMS

                         Code      Create  a web page  that  checks  whether a person is eligible  to  vote  based  on
                           9       their age.

                      <!DOCTYPE HTML>
                      <HTML>
                      <HEAD>                                                    Create a simple web page using HTML,
                      <TITLE>VOTE ELIGIBILITY</TITLE>                          CSS and JavaScript to display a greeting
                      </HEAD><BODY>                                                message when a button is clicked.
                      <SCRIPT>
                      var age = prompt("Enter your age:");

                      if (age >= 18) {
                      document.write("<H2>You are eligible to vote! </H2>");
                      }
                      else {
                      document.write("<H2>You are not eligible to vote. </H2>");

                      }
                      </SCRIPT>
                      </BODY>
                      </HTML>
                      The output of the preceding HTML code is as follows:

                       116
                            CodePilot (V5.0)-VIII

| 113 114 115 116 117 118 119 120 121 122 123 |