0

问题是没有任何验证。我可以将表格留空,它不会发出警报

<html>
<body>

<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
    function validateForm() {

        var x = document.forms["myform"]["fname"].value;

        if (x == null || x == "") {
            alert("Enter your certificate address first.");
        } else if(!x.match(/facebook/g) || !x.match(/access_token/g)) {
            alert("Invalid certificate address, please try again...");
return false;
        }
)

</script>

<form name="myform" action="welcome.php" method="post" onsubmit="return validateForm();">
Name: <input type="text" name="fname">
<input type="submit" value="submit">
</form>

</body>
</html>

不知道这有什么问题。看起来很拘谨

4

1 回答 1

2

缺少最后一个结束括号。将)更改为}

于 2013-08-19T14:15:55.763 回答