0

I want to show loading icon in submit input and message alert after submit input is clicked. I use setTimeout() set 3 second show message alert. All browser on computer or phone is ok. But with all browser of Iphone from Ios 12 - 14 not show message alert or icon loading. I guess the error is setTimeout() function.

Could anybody help me?

Here's my code:

    <form id = "commentform">
    <input id="author" name="author" type="text" value="" aria-required="true">
    <input id="email" name="email" type="text" value="" aria-required="true">
    <select name="rating" id="rating">
        <option value=""> Rate… </option>
        <option value="5"> Perfect </option>
        <option value="4"> Good </option>
          <option value="3"> Average </option>
        <option value="2"> Not that bad </option>
        <option value="1"> Very Poor </option>
    </select>
    <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
    <input name="submit" type="submit" id="submit" value="OK">
    </form>


    <script type="text/javascript">
      jQuery(document).ready(function (e) {
       e(document).on("click", "form#commentform #submit", function (t) {
          e("span.empty-review").remove();
          var o = !e("select#rating").val(),
              a = !e("textarea#comment").val();
              b = !e("input#author").val();
              c = e("input#email").val();
              emailReg = /^\w+([\.\-\+]\w+)*\w*@(\w+\.)+\w+$/;
              f = !emailReg.test(c) && c;
          f && e(this).before('<span class="error empty-review">Wrong Email. Try again</span>');
          (o || a || b || c=="") && e(this).before('<span class="error empty-review">Please enter fields with (*). Try again</span>');
          if (o || a || b || c=="" || f) {
             t.preventDefault();
          }else{
              e(this).addClass("rvloading");// add loading icon with CSS
              setTimeout(function(){ alert("Your review sent"); }, 2000);
          } 
      });
      })
    </script>
Hakul
  • 1
  • This is probably duplicate of this https://stackoverflow.com/questions/8230380/settimeout-not-working-on-safari-mobile – Sabari Oct 04 '21 at 09:24

0 Answers0