Form fields in acordina are not geting validated - jquery-validate

I am using validationEngine for validating form fields. I have tab and inside the tab, I have two accordions. Each accordion has 4 fields. When I submit, only first accordion form fields that are opened are getting validated. Is there any way I can force to validate all the form fields and open all accordions to show the required field message? Thank you!
<div id="tabs-1">
<div id="accordion">
<h3>Select Agent</h3> <!-- First accordion title) -->
<fieldset>
<div>
<label >Agent Name or ID</label>
<input name="insuredFirsName" title="type "Agent name or id "" class="validate[required] text-input" type="text" >
</div>
<label>Age</label>
<input type="text" name="age" value="${ajaxForm.age}" maxlength="3" size="3" class="validate[required] text-input" >
</fieldset>
<h3>Application Details</h3> <!-- Second accordion title) -->
<fieldset>
<div>
<label>Contract State</label>
<select name="State" id="State" class="validate[required]">
<option value="">Choose a State</option>
<option value="IL">Illinois</option>
<option value="MN">Minnesota</option>
<option value="WI">Wisconsin</option>
</select>
</div>
<div>
<label>Application Number :</label>
<input value="" class="validate[required] text-input" type="text" name="req" id="req" />
</div>
<div>
<label>Application Number :</label>
<input value="" class="validate[required] text-input" type="text" name="req1" id="req1" />
</div>
</fieldset>
</div> <!-- Accordion close -->
<html:button property="button1" value ="Submit"></html:button>
</div> <!-- Tab-1 close -->

maybe a little late but I had this same problem, i searched on the internet and found a solution, but this will work for you:
jQuery("#digitale-aanvraag").validationEngine({
validateNonVisibleFields: true,
});
Your fields in an accordion are set to hidden so as default the validator would skip them.
Be aware that if you use this in a wizard, it won't work, because those fields are also hidden...
Anyway, GL!

Related

th:field syntax inside th:each is incorrect

I am using spring boot and thymeleaf combination for my project.
Following is the code snippet for Get controller -
#GetMapping("/split")
public String VerticalSplit(Model model) {
MessageContent messageContent0 = new MessageContent();
MessageContent messageContent1 = new MessageContent();
List<MessageContent> messageContentList = new ArrayList<MessageContent>();
messageContentList.add(0, messageContent0);
messageContentList.add(1, messageContent1);
DisplayMessage displayMessage = new DisplayMessage();
model.addAttribute("displayList", displayService.getAllDisplays());
model.addAttribute("groupList", groupService.getAllGroups());
model.addAttribute("messageContentList", messageContentList);
model.addAttribute("displayMessage", displayMessage);
return "combo_vertical_split";
}
And respective html code is as follows -
<html>
<head></head>
<body>
<div class="col-12">
<label class="form-label"> Name of Message </label>
<input type="text" name="name" class="form-control" placeholder="Enter Name Of Message" required="required" th:value="${displayMessage.name}" />
</div>
<hr />
<div th:each="messageContent, iStat : ${messageContentList}">
<h6 align="center" th:text="'Section '+${iStat.count}"></h6>
<div class="form-group">
<label class="form-label"> Select the content type </label>
<select name="messageContentType" id="messageContent" class="form-control" th:onchange="ShowHideTextMediaDiv();" th:field="${messageContent.type}"> <option class="form-select" th:value="Text">Text</option> <option class="form-select" th:value="Image">Image</option> <option class="form-select" th:value="Video">Video</option> </select>
<br />
</div>
</div>
</body>
</html>
When I am trying to load the page, i am getting error as follows -
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'messageContent' available as request attribute
The point which I am not getting is that even though I have declared the messageContent in controller, why am i getting the above mentioned error.
I tried multiple syntax of
th:field="${messageContent.type}"
as follows -
th:field="*{messageContent.type}" //its silly as i have not declared the form object but still i tried
th:field="${messageContentList[__${iStat.index}__].type}"
and few other combinations as well, but nothing worked and almost everytime i got the same error.
You're getting the Neither Bindingnor plain target... error because you have used the th:field in your HTML, but you haven't defined an object from which to bind to it.
You can add your input elements in a form element and add a th:object attribute bound to your model's messageContent object.
You can do something similar to this:
<form th:object="${messageContent}">
<div class="form-group">
<label class="form-label"> Select the content type </label>
<select name="messageContentType" id="messageContent" class="form-control" th:onchange="ShowHideTextMediaDiv();" th:field="*{type}">
<option class="form-select" th:value="Text">Text</option>
<option class="form-select" th:value="Image">Image</option>
</select>
<br />
</div>
</form>

Mailchimp - Redirect to thank you page with embedded form

I followed the following post but the redirection is still not effective ...
Mailchimp - Redirect to thank you page
I can't find a way to make it work. The embedded form is embedded here on my website:
And the html code is:
<!-- Begin Mailchimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
/* Add your own Mailchimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<form action="https://travel-homes.us18.list-manage.com/subscribe/post?u=ab5689b8019de3c007fe4634b&id=84b4167b78" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h2>Main Guest</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name <span class="asterisk">*</span>
</label>
<input type="text" value="" name="LNAME" class="required" id="mce-LNAME">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name <span class="asterisk">*</span>
</label>
<input type="text" value="" name="FNAME" class="required" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">E-mail <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-group[2217]">Apartment </label>
<select name="group[2217]" class="REQ_CSS" id="mce-group[2217]">
<option value=""></option>
<option value="1">Le Wilson</option>
<option value="2">Le Rebberg</option>
<option value="4">Le Bright'n Cosy|Comfy Studio - City Center</option>
<option value="8">L'Alsacien</option>
<option value="16">L'EastSide</option>
<option value="32">Le Pfeffel</option>
<option value="128">Le Bredele</option>
<option value="256">Colmar Unique Apartment</option>
</select>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_ab5689b8019de3c007fe4634b_84b4167b78" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Send" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->
I hope somebody can find a solution to this unsolvable issue.

attributes in form that define in modal does not get dynamic value in laravel :(

I created a table for editing the Movie Object.
One of the table's column is a form that pops up with a modal class (bootstrap)
Here is my code:
<div class="modal-body">
<form method="post" action="{{asset(route('movies.update', $movie->id))}}">
<input type="hidden" name="_token" value="{{csrf_token()}}">
{{method_field('PATCH')}}
<div class="form-group">
<label for="movie-name" class="col-form-label">Name:</label>
<input type="text" class="form-control" name="movie_name" id="movie-name" placeholder="{{$movie->name}}">
</div>
<div class="form-group">
<label for="movie-director" class="col-form-label">Direcor:</label>
<select class="form-control" name="Director">
#foreach($directors as $director)
<option value="{{$director->id}}">{{$director->name}}</option>
#endforeach
</select>
</div>
<button class="form-control btn btn-success" type="submit" class="btn btn-primary">Send message</button>
</form></div>
When I choose one of the edit buttons, the value of the first item (movie) passes to my controller.
I've tested my code and find out it's happening because I have used the modal class.
Do you have any ideas to solve this problem?

Laravel Blade template checkbox checked when another one is checked

I have the following checkboxes in view
<div class="form-group">
<label class="col-md-4 control-label">Roles</label>
<div class="col-md-6 col-md-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" name="data_entry"> Data Entry <br />
<input type="checkbox" name="save_on_ext_hd"> Save On External HD <br />
<input type="checkbox" name="print"> Print <br />
<input type="checkbox" name="export_csv">Export CSV <br />
<input type="checkbox" name="delete"> Delete
</label>
</div>
</div>
</div>
I am using laravel 5 and blade template.
the issue is: when click on any checkbox the first one checked and verse versa
Ex: when click pn print checkbox the data_entry checked automatically and when unchecked print data_entry unchecked.
also when check print data_entry checked and when check delete for example data_entry unchecked.
That's because all your checkboxes are inside one <label>. Labels with an input inside activate the input when clicked. So clicking anywhere inside the label will trigger all checkboxes.
Solve this by giving each its own <label>:
<label>
<input type="checkbox" name="data_entry"> Data Entry <br />
</label>
<label>
<input type="checkbox" name="save_on_ext_hd"> Save On External HD<br />
</label>
<!-- etc -->

how to quickly reset all the checkboxes on the webpage?

I have a div with checkboxes, and everytime before checking any of them I want to make sure they are cleared first. Any input on how I can do it?
The HTML code for the div consisting of checkboxes is
<div class="row_bus_groups cuke_business_group">
<div class="row">
<input class="field_checkbox cuke_partners" type="checkbox" id="SelectedBusinessGroups[0]" name="SelectedBusinessGroups[0]" value="Partners">
<label for="SelectedBusinessGroups[0]"><span class="translated_text" rel="BusinessGroups.Partners">Partners</span></label>
<input type="hidden" name="SelectedBusinessGroups[0]" value="">
</div>
<div class="row">
<input class="field_checkbox cuke_press" type="checkbox" id="SelectedBusinessGroups[1]" name="SelectedBusinessGroups[1]" value="Press">
<label for="SelectedBusinessGroups[1]"><span class="translated_text" rel="BusinessGroups.Press">Press</span></label>
<input type="hidden" name="SelectedBusinessGroups[1]" value="">
</div>
</div>
I tried doing
#browser.div(:class, "cuke_business_group").checkbox.each{ |all| all.clear }
You were close. Try this:
#browser.div(:class => "cuke_business_group").checkboxes.each {|checkbox| checkbox.clear}

Resources