I would like to create a script to check if the order quantity is less than the quantity in stock and <500.
I have two tables
Product
ID
Description
Quantity in sotck (As calculated field from child Order - sum of quantity)
...
Order
ID
Product_ID
Quantity (int)
...

thanks to udemy course i created a table-dv.js ( order-dv.js) to verify that the quantity does not exceed 500 ( and it works!

Code: Select all
function show_error(field, msg){
modal_window({
message: '<div class="alert alert-danger">' + msg + '</div>',
title: 'Error in ' + field,
close: function(){
$j('#' + field).focus();
$j('#' + field).parents('.form-group').addClass('has-error');
}
});
return false;
}
$j(function(){
$j('#update, #insert').click(function(){
/* Quantity < 500 */
var quantita = $j('#Quantita').val();
if(isNaN(quantita) || quantita < 500 ){
return show_error('Quantita', 'Inserire un numero < 500.');
}
});
})
Can anyone help me?
Ivan