2014-09-26 4 views
0

확인시 함수가 호출되었지만 HTML5 유효성 검사를 건너 뛰고 리디렉션됩니다. 현재 페이지는 정적이며 다른 유효성 검사는 없습니다.html5 유효성 검사 및 JS

<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> 

어떤 제안이?

+0

왜 거기에 5 초 지연이 있습니까? – Cerbrus

+2

Im에 뭔가 빠졌는지 확실하지 않지만 HTML5 유효성 검사는 어디에 있습니까? – Richlewis

+0

아무것도 영향을 줍니까? – tankit88

답변

1

HTML5가 실행되지 않는 이유는 자바 스크립트가 실행되고 있기 때문입니다. 전에 유효성 검사가 실행될 수 있습니다.

귀하의 onclick 동작이 실행 중입니다.이 동작은 사용자를 리디렉션하는 자바 스크립트를 실행합니다.

+0

어떻게 올바르게 설정합니까? – tankit88

+0

중복 된 질문을보고 달성하고자하는 바를 정확히 재고하십시오. "confirm.html"로 리디렉션하는 것은 양식을 제출하는 것과 같지 않습니다. –

+0

@ LegoStormtrooper님께 고마워요. – tankit88