Register  |  Login

Question Details    

   Question

Time: 17:44 - May 07, 2008     Asked by: gloria_g      Status: Answered      Points: 75   

javascript function validateForm() does not validate my form in upload.php file.

Hi, experts,

Please go to this web site:

http://www.cookword.com/upload.php

This is a form that allow users to add a recipe. You may find that:
If you click the "Submit" button, nothing will happen. the javascript validateForm() function does not work.
The javascript file is at:

http://www.cookword.com/js/upload.js

Can you show me what is wrong? Thank you.

Gloria

Ask a New Question

Become a Quomon Expert

Current Categories

 

Other Questions Needing Answers


   

Answer Discussion
Answer Discussion
Answer Summaries
Answer Summary
 
it seems to be that your form is closed out of scope

Expert:

shashi.programmer

Date:

May 08, 2008

Time:

05:04

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Hi Gloria,

I can't be sure how to go about this without the complete Script or how advanced you may be at programming so I will start with something simple. I am no expert let it be said hehe!! Here goes:

I once had trouble with my Forms not validating and it was a simple remedy. In the Form tag at the top make sure you state the Form to be validated by calling it's NAME as follows:

<form name="contactsubmission" action="submaildetails.asp" method="post" onSubmit="return validateForm(contactsubmission)";>

Then use the onClick EventHandler to call the Form that is in focus, i.e. the Form that is being filled in, with the flashing tab - (this would signify focus on this Form).

Sorry if this is to basic etc but this is my first real entry and to be honest in the little experience I have, I have noticed it is always the obvious thing's that we tend to forget or miss out.

Let me know how you get on.

Expert:

webkungfu

Date:

Jun 22, 2008

Time:

07:51

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Sorry I meant to show the onClick EventHandler so here it is:

<input class="2" type="submit" value="Submit Enquiry" onClick="return validateForm(form)";>

Good luck!

Expert:

webkungfu

Date:

Jun 22, 2008

Time:

07:54

 

Votes: Good (0) | Bad (0)
Login to rate this answer

I cant find validateForm() function anywhere in your page!

a sample for validation

<script language="javascript">
function validateForm(){
 form = document.myForm;
 fname = form.fname.value;
 fadd = form.fadd1.value;
 if(fname.length<5) {
  alert('Fill Name correctly');
  return false;
 }
 if(fadd.length<20) {
  alert('Fill Address correctly');
  return false;
 }
 return true;
}
</script>

<form name="myForm" id="myForm" method="post" action="formaction.php" onsubmit="return validateForm();">
Name: <input type="text" id="fname" name="fname" value="" /> * minimum 5 letters <br/>
Address1: <input type="text" id="fadd1" name="fadd1" value="" /> * minimum 20 letters<br/>
Address2: <input type="text" id="fadd2" name="fadd2" value="" /> * optional<br/>
<input type="Submit" id="sbt" name="sbt" value="Post Form" /><br/>
</form>
Here I have added the validation function to onSubmit EventHandler of form

or you may also attach to onClick EventHandler of submit button as webkungfu told.

cheers

Expert:

ramanvemman

Date:

Jun 25, 2008

Time:

00:35

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Question Answered

This question has been answered, and points have been rewarded to the following experts:

shashi.programmer: 5
webkungfu: 35
ramanvemman: 35

You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.

 
No summaries have been submitted yet. Want to be the first?



Respond to this question:

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

 

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

   

"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it


All Questions


Language Options

English:

www.quomon.com

Español:

www.quomon.es

Sponsors

Questions and Answers Software
Real Estate Postcards
Marketing Fulfillment