Web Form

<!DOCTYPE html>
  <html>
      <head>
          <title>Password Input Control</title>
      </head>
  <body>
      <form>
          User ID :  <input type="text" name="user_id" />
      <br>
          Password:  <input type="password" name="password" />
       <br>
           Description : <textarea rows="5" cols="50" name="description">
      <br>
<!-- Used to give a name to the control which is sent to the server to be recognized and get the value. The value that will be used if the checkbox is selected.
-->
        <input type="checkbox" name="maths" value="on"> Maths
          <input type="checkbox" name="physics" value="on"> Physics
        <br>
        <input type="radio" name="subject" value="maths"> Maths
          <input type="radio" name="subject" value="physics"> Physics
        <br>
        <!-- Used to give a name to the control which is sent to the server to be recognized and get the value. 
       -->
            <select name="dropdown">
              <!-- The value that will be used if an option in the select box box is selected. -->
              <option value="Maths" selected>Maths</option>
              <option value="Physics">Physics</option>
             </select>
            <br>
          <input type="file" name="fileupload" accept="image/*" />
          <br>
            <!-- button -->
            <input type="submit" name="submit" value="Submit" />
            <input type="reset" name="reset"  value="Reset" />
            <input type="button" name="ok" value="OK"  />
            <input type="image" name="imagebutton" src="/html/images/logo.png" />
       </form>
  </body>
  </html>
  • Form Input Types

    • each input field has an associated
  • Delegating Events
  • To save memory, we can bind one event handler to a single ancestor element that serves multiple descendants, or enable event handling for a new created elements.
  • Form Events

    • blur: lose focus

    • change: value changed

    • focus: element is focused

    • select: text in the form is selected

    • oninvalid: occurs when a submittable element is invalid

    • submit: form is submitted

      // jQuery approach
      $("form").submit(function (e) {
         if ($("input").val() == 0) {
           // to interrupt the action of the form
             e.preventDefault(); // or return false; 
         }
       });
      
      // javascript approach 
      document.getElementsByTagName("form")[0].submit();
      

results matching ""

    No results matching ""