jquery-validate

Styling `Select2` in line with `bootstrap4` and displaying error/success with `jQuery validation` [duplicate]

送分小仙女□ 提交于 2021-01-29 16:06:54
问题 This question already has answers here : Error placement, Select2 (2 answers) How to make select2 work with jquery.validation plugin? (15 answers) select2 and jquery validation not working properly (2 answers) Closed 9 months ago . Not duplicate This question should be reopened as previous questions (on this topic) with answers are 4-5 years old and refer to respective project's old versions. Not to mention that year in computing is like a 'light year' in real life. Please vote to reopen this

Checking Image size using jQuery validation not working

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 08:42:25
问题 I am uploading an image to the folder but before uploading, I am checking the image extension and size. I am using jQuery validation. I checked on SO before uploading the question and I found the code. But the issue is when I am uploading an image which is less than 100kb(actual image size is 98kb) then I am getting the error "File size must be less than 5" . I tried another image which is 3.8MB but still getting the same error. Would you help me out what size of the image I have to use here?

jQuery Validation maxlength parameter based on conditional

依然范特西╮ 提交于 2021-01-29 04:55:17
问题 How to change the maxlength of a textbox using jQuery Validation based on a condition. Code SSN: { required: true, minlength: 9, maxlength: 9 } How do I change the maxlength based on an if-else condition? 回答1: Would a ternary expression be what you want ? SSN: { required: true, minlength: 9, maxlength: ((condition)?true:false) } Exemple : SSN: { required: true, minlength: 9, maxlength: ((my_var=="short")?13:17) } Would print 13 if the condition is met, otherwise 17 Edit: Correcting the max

jQuery - remote validation rule

a 夏天 提交于 2021-01-28 18:45:14
问题 <script type="text/javascript"> $(document).ready(function() { jQuery(function($){ $("#form").submit(function(e){ if ($(this).valid()){ $.ajax( { type: "POST", url: "http://localhost/My/modules/validate.php", }); } return false; })}); $("#form").validate({ rules: { user: { remote: { url: "http://localhost/My/modules/validate.php", async: false, } } } }); }); $.validator.setDefaults({ debug: true, success: "valid", }); </script> I want to create remote validation rules. This example correctly

jQuery - remote validation rule

偶尔善良 提交于 2021-01-28 18:32:07
问题 <script type="text/javascript"> $(document).ready(function() { jQuery(function($){ $("#form").submit(function(e){ if ($(this).valid()){ $.ajax( { type: "POST", url: "http://localhost/My/modules/validate.php", }); } return false; })}); $("#form").validate({ rules: { user: { remote: { url: "http://localhost/My/modules/validate.php", async: false, } } } }); }); $.validator.setDefaults({ debug: true, success: "valid", }); </script> I want to create remote validation rules. This example correctly

Jquery validate - show messages with Toastr

淺唱寂寞╮ 提交于 2021-01-28 10:51:46
问题 I'm using jquery validate.js for validating a form. I want to show the validation messages as Toastr popups, I've tried to add the Toastr function like this : .... messages: { "email": { required: function() { toastr.warning("Warning") }, email: "Email is invalid" } }, .... but it's keeps duplicate the popup for some reason - and instead of one popup - it creates 3.... I want to prevent messages duplication also - so if there is an error message than only one will displayed - no matter how

jQuery validation - only show one error message

房东的猫 提交于 2021-01-27 16:28:38
问题 Is there a way to only show the latest error-message thrown, when using the validation-plugin for jQuery? 回答1: I think you should look into the groups and errorPlacement options to the validate method. That should work out for you. jQuery Validation validate( [options] ) 来源: https://stackoverflow.com/questions/1816702/jquery-validation-only-show-one-error-message

jquery validation is not getting fired for checkboxes

守給你的承諾、 提交于 2021-01-21 11:06:24
问题 I have a form where I am using jQuery validation to do validation from front end side. Most of the validation are working as I want it to. However , for the checkboxes, the validation not working. I have the following rules and messages in my validation jquery $('#submitDetails').validate({ // 1. validation rules. rules: { ...... ...... ...... custom9: { required: true }, custom10:{ required:true }, custom11: { required: true } }, // 2. Validation fail messages messages: { custom9: { required

jQuery Validate with Summernote Editor error: Cannot read property 'replace' of undefined

老子叫甜甜 提交于 2021-01-21 06:19:59
问题 I am using MVC5 to build a form with summernote editor. Razor code: <div class="form-group"> @Html.LabelFor(model => model.Content, htmlAttributes: new { @class = "control-label" }) @Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control post-content"} }) @Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" }) </div> JS: $('#blog-form .post-content').summernote({ height: 400, minHeight: 300, codemirror: { theme: 'default' } })

jQuery Validate with Summernote Editor error: Cannot read property 'replace' of undefined

和自甴很熟 提交于 2021-01-21 06:19:19
问题 I am using MVC5 to build a form with summernote editor. Razor code: <div class="form-group"> @Html.LabelFor(model => model.Content, htmlAttributes: new { @class = "control-label" }) @Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control post-content"} }) @Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" }) </div> JS: $('#blog-form .post-content').summernote({ height: 400, minHeight: 300, codemirror: { theme: 'default' } })