Hi there,
I create a page to let me key in some customer information for booking, because one booking may have more than 1 customer, so i declare the entire customer info table as a variable, so can let me create how many customer i want to key in for this booking, in php i use loop to insert the data into DB, it was work fine, but when i try to do validation for the field, it totally not working, below is my code:
[CODE]
function validate_required(field,alerttxt)
{
with (field)
{
alert(field);
if (value==null||value==””)
{
alert(alerttxt);return false
}
else
{
return true
}
}
}
function validate_form(thisform)
{
var cond = parseInt(document.getElementById(“txt_amountCust”).value);
var name = “txtname_”;
var ic = “txtIc_”;
var addr = “txt_addr_”;
var poskod = “txt_poskod_”;
var phone = “txt_phone_”;
var hpnumber = “txt_hpnumber_”;
with (thisform)
{
for(var i=parseInt(1);i<=cond;i++)
{
if (validate_required(nama+i,”Name must be filled out!”)==false)
{
nama+i_.focus();
return false
}
if (validate_required(ic+i,”IC must be filled out!”)==false)
{
ic+i.focus();
return false
}
if (validate_required(addr+i,”Alamat must be filled out!”)==false)
{
addr+i.focus();
return false
}
if (validate_required(poskod+i,”Poskod must be filled out!”)==false)
{
poskod+i.focus();
return false
}
if (validate_required(phone+i,”Phone Number must be filled out!”)==false)
{
phone+i.focus();
return false
}
if (validate_required(hpnumber+i,”Other Phone must be filled out!”)==false)
{
hpnumber+i.focus();
return false
}
}
}
}
i try to track the problem, and in my code
[CODE]
function validate_required(field,alerttxt)
{
with (field)
{
alert(field);
if (value==null||value==””)
{
alert(alerttxt);return false
}
else
{
return true
}
}
}
i use alert(field) to track and found that field name that pass are correctly, and getting the error “value is no defined”, may i know is it i miss out anything, i was trying almost a day here just to find out this problem, any expert can help?
Thanks and best regard
Kc