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

showInputError #57

Open
AshotN opened this issue Feb 12, 2017 · 2 comments
Open

showInputError #57

AshotN opened this issue Feb 12, 2017 · 2 comments

Comments

@AshotN
Copy link

AshotN commented Feb 12, 2017

Is there any way to use showInputError

Like this example

swal({
  title: "An input!",
  text: "Write something interesting:",
  type: "input",
  showCancelButton: true,
  closeOnConfirm: false,
  animation: "slide-from-top",
  inputPlaceholder: "Write something"
},
function(inputValue){
  if (inputValue === false) return false;
  
  if (inputValue === "") {
    swal.showInputError("You need to write something!");
    return false
  }
  
  swal("Nice!", "You wrote: " + inputValue, "success");
});
@chentsulin
Copy link
Owner

I don't have a chance to implement showInputError as declarative api, but you can call it directly:

import swal from 'sweetalert';

<SweetAlert
  show={this.state.show}
  title="An input!"
  text="Write something interesting:"
  type="input"
  showCancelButton
  closeOnConfirm={false}
  animation="slide-from-top"
  inputPlaceholder="Write something"
  onConfirm={inputValue => {
    if (inputValue === '') {
      swal.showInputError('You need to write something!');
      return;
    }
    this.setState({ show: false });
  }}
/>

@AshotN
Copy link
Author

AshotN commented Feb 13, 2017

Thank you :)

Do you want to keep the issue open and implement showInputError later or is this enough to just close it

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

2 participants