Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent typing in input filed #17

Closed
krishnaGmail opened this issue Sep 28, 2019 · 7 comments
Closed

prevent typing in input filed #17

krishnaGmail opened this issue Sep 28, 2019 · 7 comments

Comments

@krishnaGmail
Copy link

krishnaGmail commented Sep 28, 2019

Hello Sir,

Your plugin is working well for me. Thanks to that.
But when I try to type a text in the input field of an angular-mydatepicker directive it is enabled to typing there. Plz, help me out how to prevent typing text in angular-mydatepicker.

Thank You

@kekeh
Copy link
Owner

kekeh commented Nov 10, 2019

You can set input box disabled or readonly.

<input angular-mydatepicker disabled />
or
<input angular-mydatepicker readonly />

@kekeh kekeh closed this as completed Nov 10, 2019
@krishnaGmail
Copy link
Author

krishnaGmail commented Nov 11, 2019 via email

@kekeh
Copy link
Owner

kekeh commented Nov 17, 2019

If you are using version 0.2.1 you can also use div as a host element. Then the date field is not editable.

See example code from here: https://github.com/kekeh/angular-mydatepicker/tree/master/example/app/date-picker-div-host-element

Check also the divHostElement option from the README.

@9marta5
Copy link

9marta5 commented Mar 26, 2020

Hi, if I set input box disabled, the value of the angualr-mydatepicker is doesn't show.
My input box is like this:

<input class="input-box" angular-mydatepicker
                                    (dateChanged)="onDateChange($event,row,allColumns[i])" name="mydate"
                                    [locale]="locale" (click)="dp.toggleCalendar()" [(ngModel)]="row[0].DateContent"
                                    [ngModelOptions]="{standalone: true}" #dp="angular-mydatepicker"
                                    autocomplete="off" [disabled]="!allColumns[i].colDef.Editable" />

@kekeh
Copy link
Owner

kekeh commented Mar 26, 2020

Hi @9marta5

You can try to do it this way:

public disabled: boolean = true;
<input name="mydate" [attr.disabled]="disabled ? '' : null" />

In above if the value of the disabled member is true then there will be disabled attribute in the input box, otherwise not.

I have done it that way here in my test application and it works.

Here is instructions on how to run the test application.

@9marta5
Copy link

9marta5 commented Mar 26, 2020

Hi @kekeh thank you so much. It works!

@sofianekorbi
Copy link

Hi @9marta5

You can try to do it this way:

public disabled: boolean = true;
<input name="mydate" [attr.disabled]="disabled ? '' : null" />

In above if the value of the disabled member is true then there will be disabled attribute in the input box, otherwise not.

I have done it that way here in my test application and it works.

Here is instructions on how to run the test application.

Thanks for the trick !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants