ckeditor validation for spaces -


How can I apply verification to ckeditor to prevent the user from simply adding spaces

Of the following, I've tried verification:

  // ckeditor $ ("Save note from input .save_note"). Click (function () {var note_ id1 = $ (this) .attr ("rel"); var thiss1 = this; var profile_user_id = $ (this) .attr ("rel1"); var txt = ckeditor.instances.editor1 .getData (); var no_space_txt = txt.replace ("& amp; nbsp;", ""); // var txt = txt1.replace (/ + (? =) / G, ''); var editor_val1 = CKEDITOR .instances.editor1.document.getBody (). GetChild (0) .gettext (); var editor_val = editor_val1.replace (/ + (? =) / G, ''); // if (editor_val == "") // {// warning ('sak'); // return; // if (editor_val! == "" & amp; editor_val! == "") {$ (this) .attr ("(" URL " , "Disabled"); var loading_emg = ad loading image ($ (this), "before"); jQuery.ajax ({url: "/" + PROJECT_NAME + "profile / save-note-" editor ", type:" Post ", data release : "Jason", data: {"profile_user_id": profile_user_id, "note": txt}, expiration: 50000, success: function (JSData) {if (jsonData) {$ ("P # clickable_note _" + note_id1). Hide (); $ (Thiss1) .hide ();. $ (Thiss1) .siblings ("input.edit_note") fadein (); $ ("duration #" + loading_img) .remove (); . Deleting $ (".warning-box"); . $ ("Notice-box1") removal (); . Deleting $ (". Info-box2"); ShowDefaultMsg ("note saved successfully.", 1); $ (Thiss1) .removeAttr ('Disabled'); // $ (".cke_inner cke_reset"). Hide (); CKEDITOR.instances.editor1.destroy (); Hide $ (".Press1"). $ ("P # clickable_note _" + note_id1) .html (jsonData) to display saved notes in clickable p tags; // $ ("P # clickable_note _" + note_id1) FadeIn ('slow'); // Note after editing and saving the notes to display the paragraph. } And {$ (thiss1) .removeAttr ('disabled'); $ (Thiss1) Before ('& lt; span class = "spanmsg" id = "note-msg" style = "color: red;" & gt; server error ;); }}, Error: work (xhr, ajaxOptions, thrownError) {warning (thrownError + "\ r \ n" + xhr.statusText + "\ r \ n" + xhr.responseText); }}); } And {warnings ("You can not create blank notes, please enter some text."); }});  

I have applied the warning to check that no text has been entered but I want to know whether the user is just entering the blank space or not. Please suggest some exact way.

Since you're clearly using jQuery, you add it as An additional check for your situation:

  jQuery.trim (editor_val) .length! = 0  

This will trim all the submitted space and will check whether there is any remaining balance if the input is only of white space, the statement false . You will integrate it into the following line:

  if (editor_val! = "" & Amp; amp; amp; editor_value! = "" & Amp; amp; amp; amp; amp; amp; jQuery.trim (editor_val) Length! = 0)  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -