0

だから私は、電子メールアドレスを受け入れ、それらをWebフォームに送信するhtmlでjavascript関数を作成しようとしています。どうすればいいですか?これは私がこれまでに持っているものです:

<html>
<form name="form" method="post" action="form-action.php">
<label>
Email:
</label>
<input type="email" name="email"
id="email" size="25" />

<input type="button" value="Submit" onclick="SubmitEmail()" />
</form>
<script type="text/javascript">
    function SubmitEmail() {

                if (!ValidateForm()) {

                    return false;

                }


                document.getElementById("form").submit();
function ValidateForm() {
if (document.getElementById('email').value.length === 0) {

alert("Email is Required");

return false;

}

document.getElementById('EmailRslt').value = document.getElementById('email').value;

return true;

}

</script> 
<td>Your Email is:
</td>
<td id="EmailRslt"></td>
</html>
4

2 に答える 2

0

if (document.getElementById('email').value.length === 0)この行を

if (document.getElementById('email').value.length == 0)
于 2013-10-18T04:38:37.417 に答える