I know this is an old EOL thread, but I thought I should share this little trick.
If you want to make in input check in admin form before saving a product this can pretty easily be done with pure JS applied to your admin template.
We want to extend the javascript function: Joomla.submitbutton
and here is how it´s done, an example where I check if long_desc
is longer than 4999 chars (using MCE content editor):
jQuery(document).ready(function(){
Joomla.submitbutton = (function() {
var cached_function = Joomla.submitbutton;
return function(str) {
if(jQuery(".layout-product_edit #product_desc_parent iframe#product_desc_ifr").contents().find("body.mceContentBody").length) {
var longdescrvar = jQuery(".layout-product_edit #product_desc_parent iframe#product_desc_ifr").contents().find("body.mceContentBody").html().length;
if(longdescrvar > 4999){
alert("Long description must not be more than 4999 characters. There currently is: " + longdescrvar);
return false;
}
else {
cached_function.apply(this, arguments); // use .apply() to call it
}
}
else {
cached_function.apply(this, arguments); // use .apply() to call it
}
};
}());
});