1、效果图:
附件中
2、JS验证方法:
var min=1;
function reg(x) {
jQuery('#J_Tip').html("");
jQuery('#J_Tip').hide();
return new RegExp("^[1-9]\\d*$").test(x);
}
function amount(obj, mode) {
var x = jQuery(obj).val();
if (this.reg(parseInt(x))) {
if (mode) {
x++;
} else {
x--;
}
} else {
jQuery('#J_Tip').html("请输入正确的数量!");
jQuery('#J_Tip').show();
jQuery(obj).val(1);
jQuery(obj).focus();
}
return x;
}
function reduce(obj) {
var x = this.amount(obj, false);
if (parseInt(x) >= this.min) {
jQuery(obj).val(x);
} else {
jQuery('#J