The JavaScript code would be something like this:
Code: Select allvar formId = $("form").prop("id");
$("#"+formId).setOnchange( function(fieldId, newVal, oldVal) {
var aMatch = fieldId.match(/^\[productsList\]\[(\d+)\]\[productCode\]$/);
if (aMatch) {
var rowNo = aMatch[1];
//0 is the column number of the ProductType field:
var productType = $("#productsList").getValue(rowNo, 0);
if (productType == "equipment") {
if (newVal.match(/^[A-Z]{3}$/) == null) {
alert("Product code must be three uppercase letters.");
}
}
else if {
productType == "services") {
if (newVal.match(/^[A-Z0-9]{5}$/) == null) {
alert("Product code must be five uppercase letters or numbers.");
}
}
}
});
Where the grid ID is productsList, and the grid contains two fields with the IDs "productType" and "productCode".