global variable

I am retriving three different values from three different functions and i have to perform editchecks so i call one func to do those but how do i get those values in this editcheck func from those three func, problem is i cant use global var provision ....as i have to reduce code
[280 byte] By [jitesh] at [2007-11-19 11:07:12]
# 1 Re: global variable
Here's is how I "editcheck" two fields with just one function.

<html>
<head>
<script language=javascript>
function edit_check(a_field)
{
if (a_field.value.length < 1) {
alert("Mandatory field");
a_field.focus();
return false
}
return true
}
function check_fields(a_form)
{
// Loop on each element of the form
for(i = 0; i < a_form.elements.length ; i++) {
if (a_form.elements[i].type == "text") {
// Test only input fields
if (check_field(a_form.elements[i]) == false)
return false
}
}
// It's ok, submit the form
a_form.submit()

return true
}
</script>
</head>
<body>
<form name="my_form" onsubmit="return check_fields(this)" method=get action="my_next_form.htm">
Field 1<input type="text" name="field1" size="5"><p>
Field 2<input type="text" name="field2" size="5"><p>
<input type="submit" value="Validate">
</form>
</body>
</html>
olivthill at 2007-11-8 0:21:16 >