How do I...

Results 1 to 2 of 2

Thread: How do I...

  1. #1
    Join Date
    Dec 1969

    Default How do I...

    I am using javascript to validate the date entered in a text box and would like to execute the Javascript upon the user leaving the field. How do I do that? I know you can do it with the OnClick event with a button but that's not feasible for this form.

  2. #2
    Join Date
    Dec 1969

    Default onBlur or onChanged

    ...instead of onClick.<BR><BR>Note that if you send the focus back to that field then you also need to cancel the action, by returning false from the function.<BR><BR>&#060;INPUT Name="StartDate" onChange="return checkDate(this);"&#062;<BR><BR>function checkDate( fld )<BR>{<BR> var val = fld.value;<BR> ... do your validation ...<BR> if ( ! valid )<BR> {<BR> alert( "The date you entered in " + + " is invalid.");<BR> fld.focus( );<BR> return false;<BR> }<BR> return true; // if all is okay<BR>}<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts