Topic: Calling Two Different Functions onSubmit (Read 4633 times)
Pinoy Webmaster
.com pimp
Gender:
Posts: 1126
6048 credits Members referred : 0
Philippine Beaches
« on: Sep 19, 2007, 04:26:46 pm »
guys, here i go again:
i have two functions i want to call when my user clicks the submit button in my form. how should i do it? here is the code i found on the web:
Function 1
Code:
<script>
/* Check required form elements script- By JavaScript Kit (http://javascriptkit.com) Over 200+ free scripts here! */
function checkrequired(which){ var pass=true if (document.images){ for (i=0;i<which.length;i++){ var tempobj=which.elements[i] if (tempobj.name.substring(0,8)=="required"){ if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){ pass=false break } } } } if (!pass){ alert("One or more of the required fields are not completed. Please complete them, then submit again!") return false } else return true } </script>
onSubmit="return checkrequired(this)"
Function 2
Code:
function onSubmitForm( f, ext ){ //(C)2006 Stephen Chalmers
if( allBlank ) alert("Please click on 'Browse' and select a file to upload.") else if( badName ) alert( 'A required .'+ext+' extension was not found in:' + badName );
the two functions work separately but when i call the two, it doesnt anymore. is there anything wrong with the code?
i think the problem is this, btw you need these functions together like: if all fields are valid then validate the file name...
Pinoy Webmaster
.com pimp
Gender:
Posts: 1126
6048 credits Members referred : 0
Philippine Beaches
« Reply #6 on: Sep 19, 2007, 06:59:03 pm »
tried it on my own but i wasnt able to make it work. any help with the code for combining or calling the two functions at the same time will be very much appreciated!
« Last Edit: Sep 19, 2007, 07:57:19 pm by vbignacio »
First of all, can you explain what exactly do you want to do?
he is trying something similar to my demo link
Pinoy Webmaster
.com pimp
Gender:
Posts: 1126
6048 credits Members referred : 0
Philippine Beaches
« Reply #9 on: Sep 20, 2007, 09:46:55 am »
thanks. i just want to validate a form for the required fields and the file name of the photos to be uploaded just using javascript. i cant do it server side because i already have php functions implemented and i dont want to complicate it further, me not being a programmer...
even if i convert those dangerous file or scripts into .jpeg file, are they still dangerous?
I guess this should be answered by a Linux guru
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 5799
46391 credits Members referred : 3
« Reply #17 on: Sep 20, 2007, 07:49:31 pm »
As far as I know nothing is dangerous unless you do it
If you are moving the files to a standard directory, and you are not using those files to run code (which would be impossible with php anyway) you wont have any problems.
As far as I know nothing is dangerous unless you do it
If you are moving the files to a standard directory, and you are not using those files to run code (which would be impossible with php anyway) you wont have any problems.