Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
#errmsg
{
color: red;
}
</style>
</head>
<body>
Number : <input type="text" name="age" id="age" /> <span id="errmsg"></span>
<script>
$(document).ready(function () {
//on keypressed in textbox
$("#age").keypress(function (e) {
//if not numeric, then it don't let you type
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
});
</script>
</body>
</html>
The most helpful JQUERY solutions