﻿
Ext.namespace('Ext.ux');Ext.ux.UTF8Length=function(s){if(s===null)
return 0;var l=0;for(var i=0;i<s.length;++i){var code=s.charCodeAt(i);if(code<=0x7F){l+=1;}else if(code<=0x7FF){l+=2;}else if(code>=0xD800&&code<=0xDBFF){++i;l+=4;}else{l+=3;}}
return l;};Ext.override(Ext.form.TextField,{validateValue:function(value){var len=Ext.ux.UTF8Length(value);if(len<1||value===this.emptyText){if(this.allowBlank){this.clearInvalid();return true;}else{this.markInvalid(this.blankText);return false;}}
if(len<this.minLength){this.markInvalid(String.format(this.minLengthText,this.minLength));return false;}
if(len>this.maxLength){this.markInvalid(String.format(this.maxLengthText,this.maxLength));return false;}
if(this.vtype){var vt=Ext.form.VTypes;if(!vt[this.vtype](value,this)){this.markInvalid(this.vtypeText||vt[this.vtype+'Text']);return false;}}
if(typeof this.validator=="function"){var msg=this.validator(value);if(msg!==true){this.markInvalid(msg);return false;}}
if(this.regex&&!this.regex.test(value)){this.markInvalid(this.regexText);return false;}
return true;}});Ext.apply(Ext.form.VTypes,{soname:function(val,field){val=val.replace(/^\s+|\s+$/g,'');if(val.indexOf('/')>0){return false;}
if(Ext.ux.UTF8Length(val)>255)
return false;return true;},sonameText:__tr('The object name must be 255 characters or less and may not contain \'/\'')});