There is a TextBox that I want to allow users to simply enter numbers, not any alphabetical characters. So, how could I ignore those characters entered by the end user via JavaScript or jQuery? Note that I do not want to replace the user-entered value with an empty string; Instead, you want to ignore the case if there is any way to do this.
try this code:
$("#id").keypress(function (e) { //if the letter is not digit then display error and don't type anything if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) { return false; } });
link http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html "
, , , (/ ..).
jQuery, : http://bassistance.de/jquery-plugins/jquery-plugin-validation/
, , , ? ?
JS, string.toLowerCase()
string.toLowerCase()
keypress. event.which, , , ( 48 57), false, .
keypress
event.which
$("input").keypress(function (e) { if (e.which < 48 || e.which > 57) return false; });
jQuery/plug in
http://www.texotela.co.uk/code/jquery/numeric/
Source: https://habr.com/ru/post/1780425/More articles:Microsoft SQL Server: создать порядковый номер в день - sqlSending an array of information - jsonWhat is the relationship of DBD :: Mysql with ODBC? - mysqlmatching a specific substring with regular expressions using awk - bashIs the sudden appearance of an unbearable desire to write some comments a sign of poor design? - javaMaintaining a unique set of elements according to various C ++ STL criteria - c ++How to test classes using access to databases and Exchange Server? - databaseRegister submissions with regions based on user rights - wpfВыполнение запроса для каждого дня за один период, превращение его в один запрос - javaIs the value i defined after: int i, j = 1; - c ++All Articles