[英]html5 validation and JS
確認后,將調用該函數,但會跳過HTML5驗證,而僅重定向。 截至目前,該頁面是靜態的,沒有其他驗證。
<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>
有什么建議么?
無法啟動HTML5的原因是因為您的JavaScript在驗證觸發之前就已運行。
您的onclick
動作正在觸發,該動作運行javascript,從而重定向用戶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.