0

$('#btn-submit-btn').click(function() {
  swal({
    title: "Submitted!",
    text: "Check out our website!",
    icon: "success",
    button: "Let's Go!",
  });

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<form action="#.php" method="post">


  <input type="text" name="UserName" id="username" placeholder="Enter name here" required>
  <br>


  <input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" name="PhoneNumber" id="number" placeholder="Enter your Number" required>
  <br><br>

  <input type="submit" value="Submit" id="btn-submit-btn" class="submitbutton">

</form>

What i want is Sweet alert only pops up when user enters both fields(popping up even without filling on fields ) , and after clicking sweetalert popups and doesn't disappear until the user clicks the "Lets go button" ( disappearing after 1 second ) and upon click it redirects user to specific url

Can someone help please?

MefAldemisov
  • 867
  • 10
  • 21
  • Is it https://stackoverflow.com/questions/37358423/how-to-redirect-page-after-click-on-ok-button-on-sweet-alert an answer to your question? – MefAldemisov Aug 06 '20 at 11:27
  • Sorry i m newbie , i checked this out but i cant figure it out where tto type setTimeout – SilverNature Music Aug 06 '20 at 11:29
  • If you want to close the window after a second, you can use `timer` argument of `swal`, if you want to make a delay before redirection, put `setTimeout` inside `then` function, if tou want to make a delay before alert, put `swal` inside `setTimeout` – MefAldemisov Aug 06 '20 at 11:55

0 Answers0