I have a form, broken down into columns of varying numbers of text boxes. The columns cannot total to greater than 100%. But all fields are not required. Here is how I do my validation:
function hiddenForm_OnSubmit()
{
var returnValue;
if ((document.form.fieldname.value > 100) || (document.form.fieldname.value < 0))
{
alert("Fieldname cannot be less than 0, or greather than 100"
;
returnValue = false;
form.fieldname.focus;
}
else if......and it goes on from there, with the same format as above. When I try to add the snippet of code below, I get an error that says "Object Expected", and a "Syntax Error". I want to make sure that if a field is not filled in, that JavaScript considers it a zero, so when I add the column together, if a value in the column has no value, JavaScript will think it's a big ole zero.
if ((document.form.field1.value == ""
|| (document.form.field1.value == null))
{
var field1 = "0" ;}
else {
var field1 = (document.form.field1.value);}
Thanks for any help.
function hiddenForm_OnSubmit()
{
var returnValue;
if ((document.form.fieldname.value > 100) || (document.form.fieldname.value < 0))
{
alert("Fieldname cannot be less than 0, or greather than 100"
returnValue = false;
form.fieldname.focus;
}
else if......and it goes on from there, with the same format as above. When I try to add the snippet of code below, I get an error that says "Object Expected", and a "Syntax Error". I want to make sure that if a field is not filled in, that JavaScript considers it a zero, so when I add the column together, if a value in the column has no value, JavaScript will think it's a big ole zero.
if ((document.form.field1.value == ""
{
var field1 = "0" ;}
else {
var field1 = (document.form.field1.value);}
Thanks for any help.