Jump to content

Regarding Student Marks Validation


heshan

Recommended Posts

Hi all,

 

I want to enter student marks to a form and i want to make sure the marks should be inserted to all the subjects, they are positive and should be within (0-100) range. Therefore i have created following validation..

 

Validations were successfully displayed..But the problem is whenever a validation say "insert values" displayes and then click on ok button suddenly the page redirects to the next page without allowing other fields to be filled..Can anyone tell me how can i avoid this problem???

 

<script type="text/javascript">
function checkForm(frm)
{
var id = frm.getElementsByTagName("input");   
for (var i = 0; i < id.length-1; i++)
{
if (id[i].value == "")
{
alert("Please insert value");
id[i].focus();
return false;
}
if (id[i].value.match(/\D+/))
{
alert("Please input positive integers only");
return false;
}
if(parseInt(id[i].value) > 100)
{
alert("Please input value less than 100");
id[i].focus();
return false;
}
}
frm.submit();
return true;
}
</script>
----------------------------------------------------------------------------
<td><input type="submit" name="Submit" id="button" value="Save" onclick="checkForm(this.form);" /></td>

Link to comment
https://forums.phpfreaks.com/topic/269380-regarding-student-marks-validation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.