Last active
August 29, 2015 14:27
-
-
Save tingwei628/f6d370bf0cc4843ad775 to your computer and use it in GitHub Desktop.
[JavaScript][ExtJS] Htmleditor validation (like allowBlank:false)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* IsValid() 驗證htmleditor 的 value值是否空白,並會排除空白情況 | |
*/ | |
//validate htmleditor | |
function IsValid(value) { | |
var div = document.createElement('div'), text; | |
div.innerHTML = value; | |
text = div.textContent || div.innerText || ""; | |
return (text.replace(/^\s+|\s+$/gm, '') != ""); | |
} | |
if(IsValid(Ext.getCmp('edit_Content').getValue())){ | |
Ext.getCmp('edit_Content').iframeEl.setStyle({ border: '1px solid #cf4c35' }); //red border style | |
edit_Content.iframeEl.dom.setAttribute('data-errorqtip', '請填寫內容'); //warning tooltip | |
} | |
else{ | |
Ext.getCmp('edit_Content').iframeEl.setStyle({ border: '' }); | |
edit_Content.iframeEl.dom.setAttribute('data-errorqtip', ''); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment