Topic: Calling Two Different Functions onSubmit (Read 1135 times)
Pinoy Webmaster
.com pimp
Gender:
Posts: 1126
6048 credits Members referred : 0
Philippine Beaches
« on: Sep 19, 2007, 05: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 );
Pinoy Webmaster
.com pimp
Gender:
Posts: 1126
6048 credits Members referred : 0
Philippine Beaches
« Reply #6 on: Sep 19, 2007, 07: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, 08:57:19 PM by vbignacio »
Pinoy Webmaster
.com pimp
Gender:
Posts: 1126
6048 credits Members referred : 0
Philippine Beaches
« Reply #9 on: Sep 20, 2007, 10: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...
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 7945
40623 credits Members referred : 3
« Reply #17 on: Sep 20, 2007, 08: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.