媛媛*小怪兽
If you have choices,choose the best! If you have no choices,do the best! 人生就是不断在学习路上进步的!!!!!!

运用焦点性质进行更改,移动鼠标立即修改成功,,,方便快捷,利用js就可解决的事为何不用呢!!!!!!没毛病~~~哈哈哈

限制input框内只能输入纯数字代码   

onkeyup = "value=value.replace(/[^\d]/g,'')"

使用 onkeyup 事件,有 bug ,那就是在中文输入法状态下,输入汉字之后直接回车,会直接输入字母

1.在html页面内写上input框

<input type="number" id="number" class="number" name="article_number" value="{$vo.article_number}" onblur="number({$vo.article_id},this);" style="width:140px;border:1px solid #000;height: 34px;line-height: 34px;font-size:18px;text-indent: 1em;"/

2.js里面写聚合焦点,失去焦点

function number ( val , _this) {  

var number = $(_this).val();
$.ajax({
data:{'id':val ,'article_number':number},
dataType:'json',
type:'post',
url:'{:url("article/change")}',
success:function ( msg ) {
if ( msg == 1) {
alert('修改成功!');
window.location.href = "{:url('article/index')}";
} else if ( msg == 0) {
alert('修改失败!');
window.location.href = "{:url('article/index')}";
}
}
});
}

 

3.效果如下图

 



posted on 2018-05-15 09:23  媛味君  阅读(327)  评论(0编辑  收藏  举报