Hello all,

I am stuck here with a problem. I want to check if someone enters a negative score on a multiple form page. I want that the edit field is red color if the score is negative.
I call htis function with the onblur event
input name="pickscorehome" type="text" class="pickedits" id="pickscorehome" onblur="checknumberhome(this.form);" onchange="Setradio(this.form);"

The problem is that there are an undefined number of forms on the page that are generated out of a database. How can i do that for each form ? Seems works only on
the first form.

Thanks for any hints.
Peter

function checknumbervisitor(f)
{
    if(parseFloat(f.pickscorevisitor.value)<0)
    {
      alert("There are no negative scores. Please enter a positive number");
      document.getElementById('pickscorevisitor').style.backgroundColor="#FF0000";
    }
    else
    {
    document.getElementById.getElementById('pickscorevisitor').style.backgroundColor="#FFFFFF"; 
    }
}

have each input tag that you want to turn red when a negative number is entered have an onblur event that triggers a general function checkelement and have them pass themselves. I don't think I am explaining this well.

<input id="input1" name="input1" onblur="checkelement(this)">
<input id="input2" name="input2" onblur="checkelement(this)">
<input id="input3" name="input3" onblur="checkelement(this)">
<script type="text/javascript">
function checkelement(element){
   if(parseFloat(element.value)<0)
   {
      alert("There are no negative scores. Please enter a positive number");
      element.style.backgroundColor="#FF0000";
   }
   else
   {
      element.style.backgroundColor="#FFFFFF";
   }
}
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.