I have form which has some mandatory fields. I have written a javascript which loops all controls and check for null or blank values. But the problem is that it is treating zero also as null. Suppose i write zero in No. Of children textbox, then it should accept that as a value instead it asks user to fill in that field.
Here is my code, pls help:
var requiredFields = new Array();
for (var i = 0; i < this.numFields; i++)
{
var fName = this.getNthFieldName(i);
var f = this.getField(fName);
if ((f.type=="text" && this.getField(fName).required && (this.getField(fName).value == null || this.getField(fName).value == '' || this.getField(fName).value == '0')) || (f.type=="radiobutton" && this.getField(fName).required && (this.getField(fName).value == "Off")) || (f.type=="checkbox" && this.getField(fName).required && (this.getField(fName).value == "Off")))
{
requiredFields[requiredFields.length] = fName;}}
var error = "Please complete the following fields: \n\n";
for (j=0; j < requiredFields.length; j++)
{
if (requiredFields[j].value == null)
{
error = error + requiredFields[j] + '\n';
var f2 = this.getField(requiredFields[j]);
f2.setFocus();
}
}
if (requiredFields.length > 0)
app.alert(error);
else
{
this.submitForm({cURL: "www.abc.com", cSubmitAs: "HTML"})
}
George Kaiser