我从头开始创建自定义js验证器,而不使用任何库。检查用户插入值是否高于0用香草js
我想通过检查来验证数字input
如果在input
标签用户插入的内容比0
是巨大的:
<label>Price
<input type="text" id="price" name="price">
</label>
尝试:
function price()
{
if (#price.value>0)
console.log('0.');
else
console.log('Incorrect');
}
你一些事情需要使用vanilla'document.getElementById('price')'来访问你的输入元素。 – lintmouse
那么,你的问题是什么? – Turnip
检查用户输入的值是否高于0用纯香草js –