Hi,
after playing the whole afternoon with Javascript templates on Moodle 2.4.x i ask for a solution to check the form with Javascript Code.
Any examples how to check if a box is checked or e textfield has input?
Ishan
Hi,
after playing the whole afternoon with Javascript templates on Moodle 2.4.x i ask for a solution to check the form with Javascript Code.
Any examples how to check if a box is checked or e textfield has input?
Ishan
<script type="text/javascript">
var numbers = /^[0-9]+$/;
var sid=document.getElementById('field_36');
if (sid.value!="") document.getElementById('field_36').readOnly = true;
function checkIt() {
if (sid.value!="" && !(sid.value.match(numbers))) {
alert('Only numbers are allowed for Student ID');
sid.value='';
}
}
sid.onblur=checkIt;
}
</script>
Paul, thank you for the snippet.
But, if I use the code inside the Database activity as a template it didn't work.
Where should I integrate the snippet?
Sorry, I'm a newbee here.