0

On confirm the function is called but it skips the HTML5 validation and just redirects. As of now the page is static, no other validation is there.

<label> Email :</label>
<input type="email" class="form-control" id="new_email"
       placeholder="Enter Email" required autofocus
       autocomplete="off" style="width:300px;"/>

<script type="text/javascript">
    function submitdetails() {
        if(confirm("Do you want to proceed")  == true) {
            document.write("Creating your Account, please wait...");
            setTimeout('window.location = "confirm.html";',5000);
        } else {
            document.write("Redirecting to home page, please wait...");
            setTimeout('window.location = "new_fss.html";',5000);
        }
    }
</script>

HTML :

<button type="submit" class="btn btn-primary" style="width:100px;margin-left:50px;" onclick="submitdetails();">Submit</button>

Any suggestions?

9
  • Why do you have that 5 second delay in there? Commented Sep 26, 2014 at 6:39
  • 2
    Not sure if Im missing something but where's the HTML5 validation? Commented Sep 26, 2014 at 6:42
  • does it effects anything? Commented Sep 26, 2014 at 6:43
  • 1
    possible duplicate of Get HTML5 validation to work with onclick? Commented Sep 26, 2014 at 6:54
  • 2
    @Cerbrus Its the HTML from his comment, it adds context. But hey, its all cool, I'm not getting in a rollback war over this. Commented Sep 26, 2014 at 6:55

1 Answer 1

1

The reason the HTML5 isn't kicking in is because your javascript is being run before the validation can trigger.

Your onclick action is firing, which runs the javascript, which redirects the user.

Sign up to request clarification or add additional context in comments.

2 Comments

Look at the duplicate question, and probably rethink exactly what you are trying to achieve. Redirecting to "confirm.html" is not the same as submitting a form.
@user3211681 If the answer solves your question, its helped to let future visitors know by accepting it using the tick. Upvoting also lets users know which questions and answers are good. Remember, only your involvement makes StackOverflow work!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.