Loading ...
Sorry, an error occurred while loading the content.

Re: Re: Having an alert box come up if a field in a form is filled in

Expand Messages
  • Jon Stephens
    There s a couple of stray characters. Also, the use of document here is incorrect. The function definition should read: function check(form) {
    Message 1 of 18 , Sep 1, 2005
    • 0 Attachment
      There's a couple of stray characters. Also, the use of "document" here is
      incorrect. The function definition should read:

      function check(form)
      {
      if(form.upLoadFile.value != "")
      {
      value = confirm("You're about to overwrite the existing file. Continue?");
      return value;
      }
      }

      In this function:

      form -> the form from which the function is called
      form.upLoadFile -> the form input "upLoadFile"
      form.upLoadFile.value -> the value of that form input

      if(form.upLoadFile.value != "")... -> if the form input named "upLoadFile" is
      not empty...

      Replace "upLoadFile" with the actual name of the file upload input.

      The form does not need to be named in order for this function to work. Using
      "this" in the function call takes care of that. When called from an event
      handler, "this" means "this element" or "the element from which this function is
      being called".

      HTH.

      cheers

      jon.

      > From: Marian Briones <mbriones@...>
      > Subject: Re: Re: Having an alert box come up if a field in a form is filled in
      >
      > I did this:
      >
      > <SCRIPT LANGUAGE="JavaScript">
      > <!--
      > function check(form)";
      > {
      > if(form.document.value != "")
      > {
      > value = confirm("You're about to overwrite the existing file. Continue?");
      > return value;
      > }
      > }
      > -->
      >
      > </SCRIPT>
      >
      >
      > I don't want to validate an incoming file; that already happens when
      > they first add an uploaded document.
      >
      > This isn't working. I put the onsubmit checkform and it isn't working.
      >
      > Grrr.......
      >
      > <FORM ACTION="/usmsadmin/minutes/add_minutes.php" METHOD="POST" ENCTYPE="multipart/form-data" onsubmit="return checkOverwrite(this);" NAME="form">
      >
      > what can I do?
      >
      >
    • Tim Sabin
      ... What Jon is referring to is that the word document , in browser JavaScript, refers to a pre-defined object, so stay away from using this. His example is a
      Message 2 of 18 , Sep 1, 2005
      • 0 Attachment
        > There's a couple of stray characters. Also, the use of "document" here is
        > incorrect.

        What Jon is referring to is that the word "document", in browser
        JavaScript, refers to a pre-defined object, so stay away from using
        this. His example is a good one.

        --Tim Sabin
      Your message has been successfully submitted and would be delivered to recipients shortly.