Design a site like this with
Get started

Function to allow numbers only using Regex

Regex to allow numbers only Solution In JQuery var checkNumbers = function (textBox) { debugger; var regexp = new RegExp('^[0-9]+$'); var check = textBox.value; if (!regexp.test(check)) { alert('Invalid Value. Please enter numbers only'); $(textBox).css('border-color', 'red'); return false; } else { $(textBox).css('border-color', 'green'); $(textBox).value = check; return true; } } In HTML @Html.TextBox("AddAge", null, new {... Continue Reading →

Blog at

Up ↑