After much trawling of the forums I'm still getting nowhere with this yet it seems such a basic request.
On my dataobject I'm using:
function onBeforeWrite(){
if(Director::is_ajax()) {
$dbrecord = DataObject::get_by_id("ItemInQuestion",$this->record['ID']);
if(strlen(strip_tags($this->Content)) > 100){
$this->record['Content'] = $dbrecord->Content;
}
}
parent::onBeforeWrite();
}
Hopefully you can see what I'm trying to do here. I'm preventing CMS users from entering any content over 100 characters in length. Whilst this works I've no way of giving the user feed back in the case that they've entered too much text. I'd like the green or red box in the bottom left which give the response of the ajax request to read something like - 'Please keep text less that 100 characters'.
Thanks chaps.