我想验证一个数是否有某些参数,例如我想确保一个数有3位小数是正数。我在互联网上的不同地方搜索,虽然我无法找到如何去做。我已经让该文本框只接受数字。我只需要其余的功能。验证十进制数
感谢,
$("#formEntDetalle").validate({
rules: {
tbCantidad: { required: true, number: true },
tbPrecioUnidad: { required: true, number: true },
}
messages: {
tbCantidad: { required: "Es Necesario Entrar una cantidad a la orden" },
tbPrecioUnidad: { required: "Es Necesario Entrar el valor valido para el producto" }
},
errorPlacement: function(error, element) {
parent = element.parent().parent();
errorPlace = parent.find(".errorCont");
errorPlace.append(error);
}
});
我想控制该文本框与喜欢的东西:基于实例here
$.validator.addMethod('Decimal',
function(value, element) {
//validate the number
}, "Please enter a correct number, format xxxx.xxx");
小数点后的数字是可选的还是强制的?换句话说,“123.4”还是“234”是一个有效的条目? – Blazemonger 2012-04-10 14:08:42
他们是可选 – 2012-04-10 14:10:17