I am learning about javascript from the book “JavaScript Bible”, but I have some difficulties.
I’m trying to understand this code:
function checkIt(evt) {
evt = (evt) ? evt : window.event
var charCode = (evt.which) ? evt.which : evt.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
status = "This field accept only numbers."
return false
}
status = ""
return true
}
Someone can explain to me?
I assume that you just want us to explain what the code does. If so, see below:
ASCII Code Reference
(source: cdrummond.qc.ca)
(source: cdrummond.qc.ca)
PS: I edited your code adding semi-colons
;which were missing.