here for each row each student marks have to be entered
ID ——– MID1 Marks — MID2 Marks
79 ——– 20 ———— 40
63 — —- 35 ———— 27
ID—————> student ID
MID1 marks—> 1st mid marks
MID2 marks—->2nd mid marks
validate for marks greater than 40, we have to enter less than 40 marks so, it is validating for 1 row only
here the code it is,
<html>
<script type="text/javascript">
function validate()
{
var m1=document.getElementById("m1").value;
if(m1>40)
{
alert("Marks cannot exceed 40");
document.getElementById("m1").value="";
document.getElementById("m1").focus();
return false;
}
else
{
return true;
}
}
</script>
<body>
<td><input id="m1" type=text size=18 onchange="return validate()"> </td>
</body>
</html>
i require all the rows have to be validated while entering the marks…..
You should try this
and in html
And Provide different ids to your each input. as same id for multiple controls are not valid html.