Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Student Enquiry Form</title>
<script type="text/javaScript">
function f1()
{
var name=document.forms["form"]["name"].value;
if(name=="")
{
alert("Please enter your Name");
return false;
} 


var num=document.forms["form"]["phone"].value;
if(num=="")
{
alert("Please enter your Mobile number");
return false;
}

var em=document.forms["form"]["email"].value;
if(em=="")
{
alert("Please enter your E-mail Id");
return false;
}

var in=document.forms["form"]["interest"].value;
if(in=="")
{
alert("Please select your preferred course");
return false;
}

var stat=document.forms["form"]["state"].value;
if(stat=="")
{
alert("Please select your state");
return false;
}

var cit=document.forms["form"]["city"].value;
if(cit=="")
{
alert("Please select your city/centre");
return false;
}
return true;
}
</script>
</head>

<body>

<form id="form" name="form" method="post" action="#">
Carrer Guidance Form

<label>Name:</label>
<input type="text" name="name" id="name" />
<label>Mobile No:</label>
<input type="text" name="phone" id="phone" />
<label>Email ID:</label>
<input type="text" name="email" id="email" />
<label>Interested In:</label>
<select  name="interest" id="interest">
    <option selected="selected" value="">Select Course interested in</option>
	<option value="183">B.A. In Airline, Tourism & Hospitality Management</option>
	<option value="182">Diploma in Professional In-Flight & Ground Staff Services</option>
	<option value="181">Advanced Diploma in Aviation & Tourism</option>
	<option value="180">Diploma in Hospitality Management</option>
	<option value="64">Bachelor of Business Administration (BBA) - Aviation</option>
	<option value="179">Master of Business Administration (MBA) - Aviation</option>
	<option value="71">Pilot Training</option>
	<option value="72">Professional in Airport Management & Customer Care</option>
	<option value="66">Diploma in Airport Management & Customer Care</option>
	<option value="60">Aircraft Maintenance Engineering</option>
	<option value="61">Aptech certified professional in Cabin Crew Services</option>
	<option value="62">Aptech certified professional in Ground Staff Services</option>
	<option value="63">Aptech certified professional in Travel & Tourism</option>
	<option value="70">Personality Development Course</option>
	<option value="291">Event Management</option>

</select>
<label>State:</label>
<select name="state" id="state">
	<option selected="selected" value="">Select State</option>
</select>
<label>Preferred City/Centre:</label>
<select name="city" id="city" >
	<option value="">Select City/Centre</option>
</select>
By clicking on submit, I allow Aptech Aviation to call me and send program information on email/sms/phone.
<button  id="submit" name="submit"   önClick="return f1()">submit</button>

</form>

</body>
</html>
Posted
Updated 15-Jun-13 4:32am
v2
Comments
karteek from heart 15-Jun-13 8:05am    
thanks in advance..........have a nice weekend
CHill60 15-Jun-13 10:34am    
Which function not calling what? Use the Improve question link to add detail to your question

Simple - you've been too lazy with your variable names.

Get a proper syntax-highlighting editor, look at all of your variable names and - voila! One of em is the wrong colour. Fix it, and it fires.
 
Share this answer
 
Problem
JavaScript
var in=document.forms["form"]["interest"].value;

if(in=="")
{
    alert("Please select your preferred course");
    return false;
}

Here in cannot be a variable name.

Solution

So, change that to some other name like interest.

Demo

Now, it is working perfectly.
Check out the Demo - [Demo] why this javascript function is not calling?[^].
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900