-
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
-
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
>
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks