Doug O'Leary wrote:
On 2005-03-17, RobB <fe******@hotmail.com> wrote:
More: just noticed you've got three text inputs named
'host_name'...if you want to leave it that way, you'll need to reference them as
'host_name[0]', 'host_name[1]', 'host_name[2]'...why not call them
what they're labeled as (on the form)?
Nope; that's a bonehead error in the perl script that I'll have to
go back and correct. Thanks for pointing that out. I copied
quite a bit of the function that resulted in that html code from
another one. Probably means I screwed that one up too.
Thanks again for your help.
Doug
No problem. Here's something a bit more useful (imo):
function empty(field)
{
return /^\s*$/.test(field.value);
}
function validate_form(els)
{
var foc = null, msg = [];
if (empty(els.host_name))
{
msg.push('Host name');
foc = foc || els.host_name;
}
if (empty(els.alias))
{
msg.push('Nagios alias');
foc = foc || els.alias;
}
if (empty(els.address))
{
msg.push('IP address');
foc = foc || els.address;
}
if (msg != '')
{
var pre = 'The following fields were incomplete:\n\n';
var post = '\n\nPlease correct & resubmit.\n';
alert(pre + msg.join('\n') + post);
if (foc && foc.focus)
foc.focus();
return false;
}
return true;
}
<tr bgcolor="silver">
<td><font color="red">host_name</font></*td>
<td><input name="host_name" length="20" type="text"></td>
<td>Host name</td>
</tr>
<tr>
<td><font color="red">alias</font></td>
<td><input name="alias" length="20" type="text"></td>
<td>Nagios alias</td>
</tr>
<tr bgcolor="silver">
<td><font color="red">address</font></td*>
<td><input name="address" length="20" type="text"></td>
<td>IP address</td>
</tr>