Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 75 Time: 17:44 - May 07, 2008  

gloria_g

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

Answer Discussion
Tutorials

 

shashi.programmer

Date:: May 08, 2008

Time:: 05:04

it seems to be that your form is closed out of scope

webkungfu

Date:: Jun 22, 2008

Time:: 07:51

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.

webkungfu

Date:: Jun 22, 2008

Time:: 07:54

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!

ramanvemman

Date:: Jun 25, 2008

Time:: 00:35

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

Question Answered

This question has been closed, 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 a Tutorial in the Tutorial Area.

Answer 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:

Forgot Your Password?

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

Answer 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:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10279

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




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



Language Options

English:

www.quomon.com

Español:

www.quomon.es