小编Joh*_*hnL的帖子

jquery 检查值是否不为 null/空或 NaN

我目前正在使用 jQuery 检查 value 是否为 Nan,并且希望将检查扩展到不为 null 或为空,但不确定如何执行此操作,这是我的代码;

<script type="text/javascript"> // ensure quantity textbox is numeric
$(document).ready(function () {
    $('[id$=txtQuantity]').change(function () {
        if(isNaN(this.value)) {
            alert("Please ensure the quantity specified is numeric");
            $(this).val("1");
        }
        else{
            $(this).val(this.value);
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

asp.net jquery

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net ×1

jquery ×1