简体   繁体   English

我只希望在文本框中输入数字(我只希望使用输入ID或类)

[英]I want only numeric in my text box (I want only work with input id or class)

This is my input field, I want right aj query code for only numeric keyword type in this field. 这是我的输入字段,我想在此字段中仅输入数字关键字类型的aj查询代码。 if user type string then can't do this . 如果用户输入字符串,则无法执行。

<input type="tel" name="jobapp_phone" class="sjb-form-control sjb-phone-number sjb-required" id="jobapp_phone" required="required" autocomplete="off" placeholder="099876 54321">

干得好

  <input type="number" name="quantity" min="1" max="5">

check this it allows only numbers in the text field 选中它,它仅允许在文本字段中输入数字

 $(function() { $('#main').on('keydown', '#onlyNumbers', function(e){-1!==$.inArray(e.keyCode,[46,8,9,27,13,110,190])||/65|67|86|88/.test(e.keyCode)&&(!0===e.ctrlKey||!0===e.metaKey)||35<=e.keyCode&&40>=e.keyCode||(e.shiftKey||48>e.keyCode||57<e.keyCode)&&(96>e.keyCode||105<e.keyCode)&&e.preventDefault()}); }) 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <div id="main"> <input id="onlyNumbers" type="text" /> </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想用js或者jquery只复制输入框中的最后一个文本 - I want to copy only the last one of the text in the input box using js or jquery 我想从多个文本输入中获取输入并将其发送到我的数据库,但是只有最后一个输入发送 - I want to take input from multiple text inputs and send them to my database, but only the last input sends 我怎样才能在我的代码中只显示我想要的文本? - How can i only show the text that i want to in my code? 我想在 Angular 9 中全局限制输入类型文本只有字母数字 - I want to restrict input type text only Alphanumeric in Angular 9 globally 我希望我的jQuery动画只能工作一次 - I want my jQuery animation to work only once 我只允许输入最多100.000 - I want to allow only up to 100.000 in an input 一个jQuery代码应用于许多输入,但我只希望它在一个预期的输入(搜索框)? - A jQuery code being applied in many input, but I want it only on a intended input which is a (search box)? 我只希望页面刷新一次 - i want my page refresh only once Textarea box will only allow one line of input- I want it to have multiple lines - Textarea box will only allow one line of input- I want it to have multiple lines jQuery keypress输入文本限制,我希望它只允许AZ和空格,但我的代码不允许“ Y”和“ Z” - jquery keypress in input text restriction, i want it to allow A-Z and white space only but my code won't allow “Y” and “Z”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM