只接受输入文本框中的数字而不使用脚本 [英] accept only number in input text box without using script

查看:39
本文介绍了只接受输入文本框中的数字而不使用脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在输入文本框中只允许数字

How to allow only number in input text box

<input type="text" name="price" id="input-country" required placeholder="Enter Your Price" accept="number">

我使用了上面的方法,但它不起作用当我在图像输入中只使用允许的类型时,我使用以下方法

i used the above method but its not working when i use only allowed type in image input i use the following method

<input type="file" class="custom-file-input" accept="image/x-png, image/gif, image/jpeg">

这个方法很好用以同样的方式如何只允许数字以及如何只允许文本,并保护表单 SQL 注入

this method works fine in same way how to allow only number and how to allow only text, and protect form SQL injection

推荐答案

单击此处查看如何仅在 HTML 中输入数字文本

如果您使用 HTML5,请使用

If you are using HTML5 then use <input type="number">

如果你真的想摆脱 SQL 注入 使用这个

If you realy wish to get rid of SQL injection Use this

这篇关于只接受输入文本框中的数字而不使用脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆