I want to validate that a number has certain parameters, for example I want to ensure that a number has 3 decimals is positive. I have searched in different places over the internet, although I could not find how to do it. I have made that text box to accept numbers only. I just need the rest of the features.
Thanks,
$("#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);
}
});
I want to control that text box with something like:
$.validator.addMethod('Decimal',
function(value, element) {
//validate the number
}, "Please enter a correct number, format xxxx.xxx");
Based on the examples here:
or with commas permitted: