hi, I'm a computer science student and I'm having trouble with my code...
this is a code for a static submit page, only needs form validation, i will add the PHP codes for mySql queries later on after i get this right...i need help, don't know whats wrong
<html>
<head>
<META http-equiv=Content-Type c><LINK
href="csslayout.css" type=text/css rel=stylesheet>
<META c name=GENERATOR>
</head>
<body>
<h2><img src="feather.jpg">Submit to Us:</h2>
<script type ='text/javascript'>
function check_entry()
{
var rname = document.getElementById('rname');
var yname = document.getElementById('yname');
var country = document.getElementById('country');
var serving = document.getElementById('serving');
var procedure = document.getElementById('procedure');
var ingredients = document.getElementById('ingredients');
// Check each input in the order that it appears in the form!
if(isAlphabet(rname, "Please name the recipe")){
if(isAlphabet(yname, "Please enter your name")){
if(isNumeric(serving, "Please enter exact number of serving.")){
if(madeSelection(continent, "Please select a Continent")){
if(madeSelection(country, "Please Choose a Country")){
return true;
}
}
}
}
}
return false;
}
function isEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus(); // set the focus to this input
return true;
}
return false;
}
function isAlphabet(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(document.submit.rname.value=="")
{
alert(helperMsg);
result=false;
}
if(elem.value.match(alphaExp)){
return true;
}else{
alert("Please use only letters");
elem.focus();
return false;
}
}
//the problem starts here, because before i added this function, the whole code worked just fine
function madeSelection(elem, helperMsg){
if(elem.value == "Please Choose"){
alert(helperMsg);
View full message