0
我非常新的角度JS。在這裏我有如下的簡單形式: test3.php:在驗證失敗IE9使用角度JS
<!DOCTYPE html>
<html ng-app>
<head>
<script src="http://code.angularjs.org/1.2.4/angular.min.js"></script>
</head>
<body>
<form name="myForm" id="myForm" ng-controller="Register" ng-submit="submit()" action="test2.php" method="post">
<label>First Name:</label>
<input type="input" name="firstname" ng-model="firstname" required>
<label>Last Name:</label>
<input type="input" name="lastname" ng-model="lastname" required>
<label>Email:</label>
<input type="email" name="email" ng-model="email" required>
<input type="submit" id="submit" value="Submit" />
</form>
<script>
function Register($scope) {
$scope.firstname = '';
$scope.lastname = '';
$scope.email = '';
$scope.submit = function() {
document.getElementById('myForm').submit();
};
}
</script>
</body>
</html>
而且test2.php:
<?php
echo $_POST['firstname'];
?>
當我加載test3.php並點擊提交而沒有填寫任何細節時,我收到消息填寫相應的字段,表單不提交到test2.php。當所有的細節輸入正確,然後如果我點擊提交,我看到$_POST['firstname]
值。這適用於Chrome和Firefox。
但在IE9中,根本沒有驗證。點擊提交後,表單會一直提交,無論字段是否爲空。
如何讓此代碼在IE9中工作? Angular JS API爲IE 8或更低版本提供幫助。
感謝您的回覆。我按照你的建議嘗試了'ngRequired',但它也沒有工作。 –
您需要自行爲IE編寫驗證< –
是的。情況正在呼喚它。 :(Thanks thanks any。 –