TenKracer
10-28-2003, 05:43 PM
I wanted to just use a function but if I don't include the window load it gives me some wierd error about the object. but now I see the errors before the page is loaded how can I stop this?
<code>
<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
window.onload = function validate()
{
valid = "true"
if (document.diabetesform.txtHbA1c.value.length == 4)
{
var validchar = "0123456789."
for (i=0; i<4; i++)
{
if (validchar.indexOf(document.diabetesform.txtHbA1c.value.substr(i,1)))
{
if (i == 2)
{
if (document.diabetesform.txtHbA1c.value.substr(2,1) == ".")
{
valid = "true"
document.getElementById("HbA1cerrors").firstChild.nodeValue = '';
}
else
{
valid = "false"
document.getElementById("HbA1cerrors").firstChild.nodeValue = 'The HbA1c field has an invalid format. Format expected; ##.#';
}
}
}
else
{
valid = "false"
document.getElementById("HbA1cerrors").firstChild.nodeValue = 'The HbA1c field has an invalid character. Format expected; ##.#';
}
}
}
else
...
</code>
<code>
<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
window.onload = function validate()
{
valid = "true"
if (document.diabetesform.txtHbA1c.value.length == 4)
{
var validchar = "0123456789."
for (i=0; i<4; i++)
{
if (validchar.indexOf(document.diabetesform.txtHbA1c.value.substr(i,1)))
{
if (i == 2)
{
if (document.diabetesform.txtHbA1c.value.substr(2,1) == ".")
{
valid = "true"
document.getElementById("HbA1cerrors").firstChild.nodeValue = '';
}
else
{
valid = "false"
document.getElementById("HbA1cerrors").firstChild.nodeValue = 'The HbA1c field has an invalid format. Format expected; ##.#';
}
}
}
else
{
valid = "false"
document.getElementById("HbA1cerrors").firstChild.nodeValue = 'The HbA1c field has an invalid character. Format expected; ##.#';
}
}
}
else
...
</code>