Then you are most likely generating a JavaScript error somewhere along the way.
Change the onsubmit button to be:
onsubmit="return (false && checkExt(this.userFile1.value,
this.userFile2.value));"
then check the lower-left corner of IE for a yellow !, or type "javascript
:" (no
quotes) into the Address bar of Mozilla/Netscape 7. If there are any errors,
they will be reported.
greg brant wrote:
[color=blue]
> so heres my script
>
> function checkExt(file1, file2) {
> alert("hello");
> files = Array(file1, file2);[/color]
Why do you put both files into an array and then access the individual
elements?
[color=blue]
> if (files[0] == "" && files[1] == ""){[/color]
if (file1 == "" && file2 == "") {
[color=blue]
> alert("Please select a file or browse our gallery");
> return false;
> }else{
> return true;
> }
> }
>
> and on the form tag i have
>
> <form action="designer2.php?upload=1" method="post"
> enctype="multipart/form-data" name="uploadForm" target="_top"
> id="uploadForm" onSubmit="return checkExt(this.userFile1.value,
> this.userFile2.value)">
>
> and i dont even get the
> alert("hello");
>
> it just submits
>
> cheers
>
> "Lee" <REM0VElbspamtrap@cox.net> wrote in message
> news:bgh12d09ao@drn.newsguy.com...[color=green]
> > "greg said:[color=darkred]
> > >
> > > i have a form made up of 2 file inputs and a submit button..
> > >the imputs are to upload images, namley jpeg's for a e-greatings thing im
> > >working on.
> > >this only works with jpegs so i have a script that will check the value[/color][/color]
> of[color=green][color=darkred]
> > >the imput tag to make sure it ends with .jpg, .jpeg.
> > >
> > >this works fine on the jubmit button using
> > >
> > >onclick="myHandler(this)"
> > >
> > >it works fane that it alerts the user that only jpegs are valid but then
> > >when the alert
> > >has been ok'd it continues to submit the form to my php script.
> > >
> > >how can i get this to cancle the submit action?[/color]
> >
> > Don't user the onclick handler of the submit button.
> > That's not even supported in all browsers.
> > Use the onSubmit handler of the form, itself, and have
> > it return true, if the form is to be submitted, and
> > false if not:
> >
> > <form action="whatever" onsubmit="return myHandler(this)">
> >[/color][/color]
--
| Grant Wagner <gwagner@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html