question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: AlertController inputs should be having minlength, maxlength options for text fields

See original GitHub issue

Feature Request

Ionic version: [x] 5.x

Describe the Feature Request As sometimes I need to show alert user and asking him for inputs alert AlertInput got options for min/max and seems those working for numeric to date fields, but what if I want to limit the length of the text that user provide, so I think maxlength and minlength should be added.

Describe Preferred Solution Just adding these to AlertInput and apply the change to the rendered input.

Additional Context This is been requested in the forum and the solution provided with “hack” but seems is not working for some reason. https://forum.ionicframework.com/t/ionic-unable-to-fix-maxlength-for-prompt-input-of-alert-controller/119472

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
liamdebeasicommented, Jun 1, 2020

Thanks for the feature request. This has been resolved via https://github.com/ionic-team/ionic/pull/21365 and will be available in an upcoming release of Ionic Framework. Thanks to @cerkiner for all the hard work in getting this feature done! 🎉

2reactions
cerkinercommented, May 14, 2020

@liamdebeasi perhaps we can have a new generic “attr” option that can set custom attributes for inputs. For example like this:

let alert = this.alertCtrl.create({
    title: 'Login',
    inputs: [
      {
        name: 'pin',
        placeholder: 'Pin Code',
        type: 'password',
        attr: { 
                maxLength: 4,
                inputmode: 'numeric',
                ...
        }
      }
    ],
    buttons: [
      {
        text: 'Cancel',
        role: 'cancel'
      },
      {
        text: 'Save',
        handler: data => {
          console.log('Save clicked');
        }
      }
    ]
  });
  alert.present();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

AlertController inputs should be having minlength, maxlength ...
As sometimes I need to show alert user and asking him for inputs alert AlertInput got options for min/max and seems those working...
Read more >
Ionic 3 Unable to fix maxlength for prompt input of alert controller
Im used my mobile application for ionic-3 I have some small issue, I want to set the max length ...
Read more >
Ionic Unable to fix maxlength for prompt input of alert controller
Im used my mobile application for ionic-3 I have some small issue, I want to set the max length dynamically, I tried but...
Read more >
ionic/docs/core.json - UNPKG
"text": "role The role of the element that is dismissing the action sheet.\nThis can be useful in a button handler for determining which...
Read more >
php javascript text input hide - You.com | The AI Search ...
JavaScript. You can filter the input values of a text <input> with the following setInputFilter function (supports Copy+Paste, Drag+Drop, keyboard shortcuts ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found