<input id="dialogPrice" type="text" class="weui-input" placeholder="¥10" />
试了好多办法都不起作用。
下面是我的代码:
//其它金额
$('#otherPriceBtn').on('click', function(e) {
var otherPrice = $('#dialogPrice').val();
getOtherPrice = otherPrice >= 3 && otherPrice <= 199;
if(getOtherPrice) {
weui.topTips('请输入3~199之间的金额!');
} else {
console.log("其它金额" + otherPrice);
var data = {
userId: userId,
price: otherPrice
};
data = JSON.stringify(data);
$.ajax({
data: {},
dataType: 'json',
type: "post",
url: url,
contentType: 'application/json; charset=utf-8',
success: function(data) {
},
error: function(data) {
location.href = 'doctor_wode.html';
}
});
}
});
给两种简单的思路
1.如果要在提交时进行判断,可以取出输入的数字去做判断
2.如果要在输入时进行判断,可以在input上绑定chang事件判断。
这个完全可以用jquery控制啊,你可以在提交表单时候判断,或者在blur判断,应该都是有作用的