I\'ve managed to validate my field so it is always four digits, but i need to validate so that it is always a number. I tried adding this block of code but it doesn\'t work
/^[0-9]{4}$/
for four numbers
/^[0-9]*$/
for any amount of numbers
/^[0-9]+$/
for at least one number
Let's say you get your value here
var val = document.ExamEntry.cand.value;
Then if you want it to be something with 4 digits inside, just do this
var itIsNumber = /^\d{4}$/.test(val); // true if it is what you want
if you want it to be something with 1 to 4 digits inside, just do this
var itIsNumber = /^\d{1,4}$/.test(val); // true if it is what you want
more examples and details here --> Regular Expressions