2

JqueryはInternetExplorerでは機能しません。ただし、他のWebブラウザで実行されます。私が書いたコードは

<html>
<head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("#myform").validate({
            debug: false,
            rules: {
                name: "required",
                email: {
                    required: true,
                    email: true
                }
            },
            messages: {
                name: "Please let us know who you are.",
                email: "A valid email will help us get in touch with you.",
            },
            submitHandler: function(form)
            {
                $.post('process.php', $("#myform").serialize(), function(data)
                {
                    $('#results').html(data);
                });
            }
        });
    });
    </script>

</head>
<body>
<form name="myform" id="myform" action="" method="POST">
    <label for="name" id="name_label">Name</label>
    <input type="text" name="name" id="name" size="30" value=""/>
    <br>
    <label for="email" id="email_label">Email</label>
    <input type="text" name="email" id="email" size="30" value=""/>
    <br>
    <input type="submit" name="submit" value="Submit">
</form>
<div id="results"><div>
</body>
</html>

process.php

<?php
    print "Form submitted successfully: <br>Your name is <b>".$_POST['name']."</b> and your email is <b>".$_POST['email']."</b><br>";
?>

このコードをINTERNETEXPLORERで実行するにはどうすればよいですか。

4

4 に答える 4

2

この行の後の「、」を削除します

email: "A valid email will help us get in touch with you.",

する必要があります

 email: "A valid email will help us get in touch with you."

あなたのメッセージブロックではこのようになっています

 messages: {
            name: "Please let us know who you are.",
            email: "A valid email will help us get in touch with you.",   // <<<< HERE REMOVE IT                
        },

最後の行の「、」(コンマ)を削除する必要があります。

于 2012-07-05T10:00:41.550 に答える
0

に追加する必要return falseがありsubmitHandlerます。

または、を使用して、送信入力をフォームを送信しないボタンに変換できます<button>Submit</button>

于 2012-07-05T09:49:14.523 に答える
0

以下のコードを試してください:-

<script type="text/javascript">
  $(document).ready(function(){
    $("#myform").validate({
        debug: false,
        rules: {
            name: "required",
            email: {
                required: true,
                email: true
            }
        },
        messages: {
            name: "Please let us know who you are.",
            email: "A valid email will help us get in touch with you.",
        },
        submitHandler: function(form)
        {
            $.post('process.php', $("#myform").serialize(), function(data)
            {
                $('#results').html(data);
            });
            return false;
        }
    });
});
</script>
于 2012-07-05T09:50:17.997 に答える
0

私は私の最後にあなたのコードを実行しようとしました。上部にDoctypeを追加してください。私は同じものを使用しましたが、以前は機能していませんでしたが、機能しました。

<!DOCTYPE html>

ありがとう

于 2012-07-05T09:52:10.560 に答える