I have form contain one date field and a button (Add date) when user click on the button a new date field appear but it doesn't work i have problem in date picker
<div class="col-md-2 right-border" id="target">
<div class="form-field field-date getdate">
<input type="text" name="Departure-FlightMultiCity" id="Departure-FlightMultiCity" class="field-input calendar-input caneldar" placeholder="Departing" style="font-size:14px;font-family:FontAwesome;height:30px">
</div>
</div>
<a id="AddAnotherFlight" class="awe-btn-lager fa fa-plus" style="margin-left:20px;cursor:pointer;font-size:14px;margin-bottom:10px;display:block">
<b> Add another Flight</b>
</a>
Related
I have website created as an angular app that has a bootstrap datepicker. The problem is that the header of this datepicker is not visible - there're no arrows or a spinner to choose a month and a year.
The code in html look like this (I just want the header to be visible, I don't cate about its functionality at this point):
<div class="btn-group mb-3 mr-3 ">
<input class="form-control "
name="datepicker"
ngbDatepicker
#datepicker="ngbDatepicker"
[autoClose]="'outside'"
(dateSelect)="onDateSelection($event)"
[displayMonths]="2"
[dayTemplate]="t"
outsideDays="hidden"
[startDate]="fromDate"
[placement]="'bottom'"
type="hidden">
<ng-template #t let-date let-focused="focused">
<span class="custom-day"
[class.focused]="focused"
[class.range]="isRange(date)"
[class.faded]="isHovered(date) || isInside(date)"
(mouseenter)="hoveredDate = date"
(mouseleave)="hoveredDate = null">
{{ date.day }}
</span>
</ng-template>
<div class="input-group-append ">
<button class="btn btn-outline-dark " (click)="datepicker.toggle()" type="button" placement="bottom" ngbTooltip="{{'raports_by_date' | translate }}"><span class="fa fa-calendar"></span></button>
</div>
<button type="button" class="btn btn-dark no-click" *ngIf="toDate" > {{fromDate.day}}/{{fromDate.month}}/{{fromDate.year}}</button>
<button type="button" class="btn btn-dark btn-sm no-click" *ngIf="toDate" >-</button>
<button type="button" class="btn btn-dark no-click" *ngIf="toDate" >{{toDate.day}}/{{toDate.month}}/{{toDate.year}} </button>
<button type="button" class="btn btn-dark no-click" *ngIf="!toDate && fromDate" >{{fromDate.day}}/{{fromDate.month}}/{{fromDate.year}} </button>
</div>
And the result I get in a browser is:
I'm new to web applications programming and I've been working on this datepicker for the last two days. I have tried following examples at: https://ng-bootstrap.github.io/#/components/datepicker/examples#adapter but to no success.
You need to make sure you have the #angular/localize package first:
if (!not) {
npm install #angular/localize --save
Then, import '#angular/localize/init' in your polyfills.ts file just like the error says
OR
ng add #angular/localize
It will take care of it automatically
}
I am using an input for the date. How do we set the Input to display the Date Today? Thank you for your time.
<div class="form-group">
<label>Debarred</label>
<input v-model="form.debarred" type="date" name="debarred"
placeholder="Debarred"
class="form-control" :class="{ 'is-invalid': form.errors.has('debarred') }">
<has-error :form="form" field="debarred"></has-error>
</div>
You can update the model value form.debarred on page load like:
this.form.debarred = new Date().toLocaleDateString('en-CA');
//==> "2020-04-03"
Now, using .toLocaleDateString('en-CA') is need here as <input type="date"> value can only accept a string representing a date in YYYY-MM-DD format, or empty.
DEMO:
const debarred = document.querySelector('[name=debarred]');
debarred.value = new Date().toLocaleDateString('en-CA');
<div class="form-group">
<label>Debarred</label>
<input type="date" name="debarred" placeholder="Debarred" class="form-control">
<has-error :form="form" field="debarred"></has-error>
</div>
How can I change dynamically where it says 40,95€/mes to the option selected in the radio buttons using AMP?
<form id="myform" method="get" action-xhr="#" target="_top">
<amp-selector class="radio-selector" layout="container" name="my-selector">
<div class="background_gris_0" option="b">
<label>
<div class="clm1 left center_input">
<input name="answer1"
value="Value 1"
type="radio"
on="change:myform.submit">
</div>
<div class="clm8 left">Antes 10GB* / AHORA 20GB / Llamadas ilimitadas / 19,95€/mes</div>
</label>
</div>
<div class="background_gris_1" option="c">
<label>
<div class="clm1 left center_input"><input name="answer1"
value="Value 2"
type="radio"
on="change:myform.submit"></div>
<div class="clm8 left">Antes 20GB* / AHORA 50GB / Llamadas ilimitadas / 24,95€/mes</div>
</label>
</div>
</amp-selector>
</form>
<div class="center">
<h1> 40,95€/mes</h1>
</div>
JS Fiddle
This can be achieved by using the amp-bind component.
First of all, I would like to suggest you to remove all change events from radio buttons in amp-selector. Shift that 'myForm.submit' action to amp-select's 'select' event.
Create a state variable called 'currentPrice'. This will be null in the beginning. But when a radio input is selected, this will have a value and update the text in the h1 element.
So, in radio buttons add this (change the value of currentPrice accordingly):
on="tap:AMP.setState({currentPrice: '19,95€/mes'})"
Then, in the h1 element do this:
[text]="currentPrice"
So whenever the radio button is tapped, the text at the bottom will be updated with price.
You can see the jsfiddle here:
Js Fiddle
I have removed form submit event for simplicity.
I want to add the ng2-bootstrap's date picker popup on top of a dropdown div that I created. When that did not work I tried to just create a simple multilevel dropdown to begin with. Eventually I want date picker popup to show up when clicked on the dropdown I have. Can you help please. Here is my code.
I am new to the community. Please let me know if I missed any information that should have been included.
import {Component} from 'angular2/core';
import {DROPDOWN_DIRECTIVES, DATEPICKER_DIRECTIVES} from "ng2-bootstrap/ng2-bootstrap";
#Component({
selector: 'multilevel-dropdown',
template: `
<div>
<div dropdown [autoClose]="'disabled'">
<div dropdownToggle id="TopLine" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<H1>Today's date is: {{dt | date:'short'}} (click date for pop-up)<b class="caret"></b></H1>
</div>
<div class="dropdown-menu">
<div class="dropdown dropdown-submenu">
<div id="FirstPopup" class="dropdown-toggle" data-toggle="dropdown" aria-labelledby="TopLine" aria-expanded="false">
<H3>First Popup (implemented as dropdown) (click this text for next popup)<b class="caret"></b></H3>
<!--Following should be replaced with the div commented later for datepicker popup-->
<div class="dropdown-menu">
<div class="dropdown dropdown-submenu">
<div id="SecondPopup" class="dropdown-toggle" data-toggle="dropdown" aria-labelledby="FirstPopup" aria-expanded="false">
<H5>Second Popup (implemented as dropdown)</H5>
</div>
</div>
</div>
<!--<div id="SecondPopup" class="dropdown-menu dropdown-menu-right" aria-labelledby="FirstPopup">-->
<!--<datepicker [(ngModel)]="dt" [showWeeks]="false"></datepicker>-->
<!--</div>-->
</div>
</div>
</div>
</div>
</div>
`,
directives: [DROPDOWN_DIRECTIVES, DATEPICKER_DIRECTIVES]
})
export class MultilevelDropdownComponent {
public dt:Date= new Date();
}
Found the fix. The issue was that each time a dropdown (at any level) is clicked, the event is propagated up the DOM and the dropdown-toggle toggles the open dropdown. In order for multilevel-dropdown to work, I needed to capture the event and stop propagation based on if I am opening the next level of dropdown or closing an existing one.
I am using bootstrap-datepicker and need to send both the date selected and a hidden value when user hits the submit button. Code is so:
<div class='input-append date datepicker' data-date=$today data-date-format='mm-dd-yyyy'>
<form class='well' action='Update_Birthday.php' method='POST'>
<input type='hidden' name='ContactID' value=$ContactID>
<input class='span5' size='16' type='text' name='date' readonly>
<span class='add-on'><i class='icon-calendar'></i></span>
<button type='submit' class='btn'>Submit</button>
</form>
</div>
If I click Submit before selecting a date, then ContactID is sent correctly (but date is null of course). When I select a date, then both 'ContactID' and 'date' are identical, i.e. the date selected by the user.
How do I send the date AND hidden values correctly?
Help appreciated.
With this code (essentially what you have already, with quotes added to values):
<div class='input-append date datepicker' data-date='$today' data-date-format='mm-dd-yyyy'>
<form class='well' id='birthdayForm' action='Update_Birthday.php' method='POST'>
<input type='hidden' name='ContactID' value='$ContactID'>
<input class='span5 dateInput' size='16' type='text' name='date' readonly>
<span class='add-on'><i class='icon-calendar'></i></span>
<button type='submit' class='btn'>Submit</button>
</form>
</div>
There's no reason ContactID should be overwritten when a user selects a date.
As for preventing form submission until a date is selected, that will require some JavaScript. I would suggest just prefilling the date input with a value (possibly the previously specified birthday, judging by your code?) - since the field is readonly, users will generally be unable to empty the value, only change the date.
If you prefer to leave it blank, something like this should help:
$('#birthdayForm').on('submit', function(e) {
$('.dateInput').each(function() {
if ($(this).val().length < 1) {
e.preventDefault();
}
});
});