Section A.6. Chapter 7


A.6. Chapter 7

  1. If using the DOM Level 0 events, returning false from the event handler and the event-handler script cancels the submittal. If using DOM Level 2, set cancelBubble to TRue for IE, and call the preventDefault for other browsers, both based on the event object.

  2. The blur event is triggered when the field loses focus. This is a good time to check the text field to make sure it has valid data.

  3. The select options are stored in an array called Options. As such, you can add new options as you would add new array elements, making sure that the entry is a new Option object:

  4. opts[opts.length] = new Option("Option Four", "Opt 4");

  5. Hereâ??s one approach:

  6. var rgEx = /^[A-Za-z\s]*$/g; var OK = rgEx.exec(document.someForm.text1.value);

  7. The code must first assign an event-handler function to each radio buttonâ??s onclick event handler:

  8. document.someForm.radiogroup[0].onclick=handleClick; document.someForm.radiogroup[1].onclick=handleClick;

  9. If there are several buttons, this can be managed in a for loop. In the handleClick function, test the check status, and disable the form element accordingly. For instance, to disable the submit button:

  10. function handleClick(â??â??) {    if (document.someForm.radiogroup[1].checked) {      document.someForm.submit.disabled=true;    } else {      document.someForm.submit.disabled=false;   } }




Learning JavaScript
Learning JavaScript, 2nd Edition
ISBN: 0596521871
EAN: 2147483647
Year: 2006
Pages: 151

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net