about client side validation


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: about client side validation

  1. #1
    Frank Y. Guest

    about client side validation


    Hi all,
    I want to do a client side form validation before it is submitted.
    The form looks like the following:

    <FORM NAME=UPLFORM ACTION="/km/index/userupload.asp?" METHOD="POST"
    ENCTYPE="multipart/form-data"> Please select a file:<br />
    <INPUT TYPE=FILE SIZE=36 NAME="uplfile"><BR>
    <INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Upload">
    </FORM>

    I want to check if the user has actually selected a file. How?

    Thanks a lot


  2. #2
    Stuart Guest

    Re: about client side validation


    Try this Frank,

    Insert the following code between the <head> tags -

    <script language="JavaScript">
    function CheckForm (aform)
    {
    if (aform.uplfile.value == "")
    {
    alert ("Please Select a file to upload!");
    }
    return !(aform.uplfile.value == "");
    }
    </script>

    And add the following onSubmit to the <form> tag -

    <FORM NAME=UPLFORM ACTION="/km/index/userupload.asp?" METHOD="POST" ENCTYPE="multipart/form-data"
    onSubmit="javascript:return CheckForm(this);">


    Hope it helps.

    Feel free to contact me is you have any trouble,

    Stuart.

    "Frank Y." <yangyuchen39@hotmail.com> wrote:
    >
    >Hi all,
    >I want to do a client side form validation before it is submitted.
    >The form looks like the following:
    >
    ><FORM NAME=UPLFORM ACTION="/km/index/userupload.asp?" METHOD="POST"
    > ENCTYPE="multipart/form-data"> Please select a file:<br />
    > <INPUT TYPE=FILE SIZE=36 NAME="uplfile"><BR>
    > <INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Upload">
    ></FORM>
    >
    >I want to check if the user has actually selected a file. How?
    >
    >Thanks a lot
    >



  3. #3
    Davis Guest

    Re: about client side validation


    It seems the file controller can input text by hand.

    "Stuart" <stuartv@prologic.com.au> wrote:
    >
    >Try this Frank,
    >
    >Insert the following code between the <head> tags -
    >
    ><script language="JavaScript">
    >function CheckForm (aform)
    >{
    > if (aform.uplfile.value == "")
    > {
    > alert ("Please Select a file to upload!");
    > }
    > return !(aform.uplfile.value == "");
    >}
    ></script>
    >
    >And add the following onSubmit to the <form> tag -
    >
    ><FORM NAME=UPLFORM ACTION="/km/index/userupload.asp?" METHOD="POST" ENCTYPE="multipart/form-data"
    >onSubmit="javascript:return CheckForm(this);">
    >
    >
    >Hope it helps.
    >
    >Feel free to contact me is you have any trouble,
    >
    >Stuart.
    >
    >"Frank Y." <yangyuchen39@hotmail.com> wrote:
    >>
    >>Hi all,
    >>I want to do a client side form validation before it is submitted.
    >>The form looks like the following:
    >>
    >><FORM NAME=UPLFORM ACTION="/km/index/userupload.asp?" METHOD="POST"
    >> ENCTYPE="multipart/form-data"> Please select a file:<br />
    >> <INPUT TYPE=FILE SIZE=36 NAME="uplfile"><BR>
    >> <INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Upload">
    >></FORM>
    >>
    >>I want to check if the user has actually selected a file. How?
    >>
    >>Thanks a lot
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center