bootstrap-wysihtml5 icon indicating copy to clipboard operation
bootstrap-wysihtml5 copied to clipboard

html5 validation don't work

Open KernelFolla opened this issue 11 years ago • 11 comments

html5 validation (required="required" for example) don't work. this appens because the original field is hidden.

this is my workaround, I hope it can be useful:)

    jQuery('.wysihtml5').wysihtml5({
        "events":      {
            "load": function () {
                jQuery('.wysihtml5').addClass('nicehide');
            }
        }
    });
.nicehide {
    resize: none;
    display: block !important;
    width: 0;
    height: 0;
    margin: 0 0 0 -15px;
    float: left;
    border: none;
}

KernelFolla avatar Jul 29 '13 15:07 KernelFolla

THAAAAAAAAAAAAAAAAAAAAAAAAAAAANK YOU! I was going crazy trying to find a way to do this!

fabicurti avatar Aug 17 '13 11:08 fabicurti

Found a PERFECT way to do the job.. here´s the code :)

I know the question is old, but maybe help somebody looking for this..

To make the JQuery Validation work with WysiHtml5, just set the plugin to not ignore hidden textareas:

$('#form').validate({ ignore: ":hidden:not(textarea)",
rules: {
WysiHtmlField: "required" }, submitHandler: function(form) { ... } });

fabicurti avatar Dec 12 '13 19:12 fabicurti

Only @KernelFolla 's solution worked for me, I also use, bootstrapwizard steps.

@KernelFolla now it shows 2 text areas vertically, I tried to fix it by margin-top:-150 but in one they can't stick togetler, other steps are fine, I getting crazy one stupid validation took my all night :)

Is there any way to hide iframe ara below textarea?

ignore: ":hidden:not(textarea)",

doesnt even work in any case with "" or else , wizard blows up.

kargaa avatar Dec 14 '13 11:12 kargaa

Ok last solution thanks to @KernelFolla , I added visibility attiribute to hide, div so it works now.

.nicehide { resize: none; display: block !important; width: 0; height: 0; margin: -200px 0 0 0; float: left; visibility:hidden; }

kargaa avatar Dec 14 '13 11:12 kargaa

@KernelFolla & @kargaa

You sir are a legend, thanks, was doing my head in trying to figure this out.

[edit] Does not work when used with responsive template.

dubwise avatar Feb 12 '14 03:02 dubwise

for me it works with responsive template but i've done a variant for multiple textarea

    jQuery(obj).wysihtml5({
       ...
    }).filter('[required]').addClass('nicehide');

KernelFolla avatar Feb 12 '14 11:02 KernelFolla

This works almost fine, if you hit the submit button before writing anything in the wysihtml5 editor, it popups the required message, but then even if you fill the wysihtml5 editor with text the message doesn't go away until you submit (again) the form. Any workaround?

jorgelbg avatar Mar 05 '14 02:03 jorgelbg

thanks you! saved my life...

BonceSkip avatar Jul 20 '14 20:07 BonceSkip

Thank you @KernelFolla ! You've made my day! :smiley:

I wanna contribute a little bit to your solution. This is my styles;

.nicehide {
    display: block !important;
    position: absolute; /*Keep the object's original position*/
    width: 0 !important; /*It should be 0 width. Otherwise the object seems underneath of the editor */
    z-index: -1; /*Send the object to the bottom layer*/
}

efkan avatar Jan 17 '15 12:01 efkan

@KernelFolla where shloud i put the class .nicehide and the jquery function help me please

BIackSouL avatar May 21 '16 10:05 BIackSouL

Thank you @efkan , your css was the one that worked for me :) and thks @KernelFolla for the idea ;)

Assem avatar Dec 28 '16 20:12 Assem