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

Maxlenght and other attributes on input? #58

Closed
ghost opened this issue Mar 3, 2016 · 2 comments
Closed

Maxlenght and other attributes on input? #58

ghost opened this issue Mar 3, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 3, 2016

First of all thanks for keeping this nice plugin alive!

So I was wondering if you could add a option to give an array of attributes to an input type, so I can add maxlenght to the input field for example.

I am using this:

title: 'Test', text: 'Enter some text', type: "input", showCancelButton: true, closeOnConfirm: false, showLoaderOnConfirm: true

@limonte
Copy link
Member

limonte commented Mar 3, 2016

Update(June 2018): There's a better way now:

swal({
  title: 'Maxlength', 
  input: 'text',
  inputAttributes: {
    maxlength: 32
  }
})

Live demo: https://jsfiddle.net/ad3quksn/1642/

The answer below is still supported, but outdated:


You can do whatever you want within the html parameter:

swal({
  title: 'Maxlength', 
  html: '<p><input id="input-field" maxlength="32">'
});

@limonte limonte closed this as completed Mar 3, 2016
@ghost
Copy link
Author

ghost commented Mar 3, 2016

Okay thanks!

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

1 participant