Hi I'm working now with form validation. How to make a regex for numbers, comma and decimals? Or in short for money value in textbox.
For example 12,100.10
jQuery(function($) {
var validation_holder;
$("form#register_form input[name='submit']").click(function() {
var validation_holder = 0;
var cost = $("form#register_form input[name='n_unit_cost']").val();
var cost_regex = /^[0-9]+$/; // reg ex cost check
if(cost == "") {
$("span.val_cost").html("This field is required.").addClass('validate');
validation_holder = 1;
} else {
if(!cost_regex.test(cost)){ // if invalid phone
$("span.val_cost").html("Integer Only is Allowed!").addClass('validate');
validation_holder = 1;
} else {
$("span.val_cost").html("");
}
}
if(validation_holder == 1) { // if have a field is blank, return false
$("p.validate_msg").slideDown("fast");
return false;
} validation_holder = 0; // else return true
/* validation end */
}); // click end
}); // jQuery End