【发布时间】:2013-12-12 20:07:38
【问题描述】:
我对 Angular JS 很陌生。这里有一个简单的表格,如下所示: test3.php:
<!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 及更低版本提供帮助。
【问题讨论】:
标签: html internet-explorer angularjs