A
Anonymous
Guest
Hello,
I'm building a web app the processes information into a DB. I'm attempting to write a JS validation page. On this page I'm also trying to make the button perform a submit only if the validation returns as true. How do I make this happen? So far, I have this for Javascript:
Somehow I would like to say if all fields are true then submit to submission.php. Could anyone give me a hand with this?
Thanks,
dlopez
I'm building a web app the processes information into a DB. I'm attempting to write a JS validation page. On this page I'm also trying to make the button perform a submit only if the validation returns as true. How do I make this happen? So far, I have this for Javascript:
Code:
function validateForm(){
var category = document.forms["maintable"]["Category"].value;
var proName = document.forms["maintable"]["ProName"].value;
//var misc = document.forms["maintable"]["Misc"].value; //This might become a requirement in the future
var dateInput = document.forms["maintable"]["dateInput"].value;
var time = document.forms["maintable"]["time"].value;
var sampleID = document.forms["maintable"]["sampleID"].value;
var panNumber= document.forms["maintable"]["panNumber"].value;
var panWT = document.forms["maintable"]["PanWT"].value;
var panSampWT = document.forms["maintable"]["PanSampWT"].value;
var moistPercent = document.forms["maintable"]["MoisturePercent"].value;
var dryWT = document.forms["maintable"]["DryWT"].value;
var minSpec = document.forms["maintable"]["MinSpec"].value;
var maxSpec = document.forms["maintable"]["MaxSpec"].value;
if(category == null || category == ""){
alert("The \"Find CAT\" field is blank. \"Find CAT\" must have a value!")
return false;
}
if(proName == null || proName == ""){
alert("The NAME field is blank. The NAME field must have a value!")
return false;
}
// if(misc == null || misc == ""){
// alert("The MISC field is blank. MISC must have a value!")
// return false;
// }
if(dateInput == null || dateInput == ""){
alert("The Date field is blank. \"Date\" must have a value!")
return false;
}
if(time == null || time == ""){
alert("The TIME field is blank. \"TIME\" must have a value!")
return false;
}
if(sampleID == null || sampleID == ""){
alert("The \"SAMPLE ID\" field is blank. \"SAMPLE ID\" must have a value!")
return false;
}
if(panNumber == null || panNumber == ""){
alert("The \"PANNO\" field is blank. There must be a Pan Number!")
return false;
}
if(panWT == null || panWT == ""){
alert("The \"PAN WEIGHT\" field is blank. There must be a Pan Weight!")
return false;
}
if(panSampWT == null || panSampWT == ""){
alert("The \"PAN + SAMPLE WEIGHT\" field is blank. There must be a value!")
return false;
}
if(moistPercent == null || moistPercent == ""){
alert("The \"% MOISTURE\" field is blank. Do you have all of the fields that require this calculation populated with a value? Please populate all of the fields required!")
return false;
}
if(dryWT == null || dryWT == ""){
alert("The \"DRIED WEIGHT\" field is blank. There must be a value in \"DREID WEIGHT!\" ")
return false;
}
if(minSpec == null || minSpec == ""){
alert("The \"MINSPEC\" field is blank. How are you supposed to tell if the product is in range if there isn\'t a minimum spec? Please select a product to get the minimum spec!")
return false;
}
if(maxSpec == null || maxSpec == ""){
alert("The \"MAXSPEC\" field is blank. How are you supposed to tell if the product is in range if there isn\'t a maximum spec? Please seslect a product to get the maximum spec!")
return false;
}
}
Somehow I would like to say if all fields are true then submit to submission.php. Could anyone give me a hand with this?
Thanks,
dlopez