Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to restrict user to input only boolean in the Form?

Is there a proper way where it restrict user to input only either true or false ? I saw that we can allow user to enter only number but how do we do for boolean ?

I tried following

<input
            type="boolean"
            [(ngModel)]="item.isApproved"
            class="form-control"
          />

But this allows user to enter any alphabet or numbers although I have defined the type is boolean.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use :

<input
                type="checkbox"
                [(ngModel)]="item.isApproved"
                class="form-control"
              />

and If you want to make checkbox size bigger you can customize scss as :

input[type="checkbox"] {
  -ms-transform: scale(3);
  -moz-transform: scale(3);
  -webkit-transform: scale(3);
  -o-transform: scale(3);
  transform: scale(3);
  padding: 40px;
  box-shadow: 2em #3b88fd;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading