私は一日中コードをテストしていますが、何も起こりません。フォームは自動的にsuccess.htmlを開き、スクリプトは使用しません。javascript/htmlを使用したフォーム検証は機能しません
\t function FormValidation(theForm) {
\t var errors = "";
\t var alph = /^[\w ]+$/;
\t var cardnumb = /^\d{16}$/;
\t var cvvnumb = /^\d{3}$/;
\t var monthnumb = /^\d{1,2}$/;
\t var yearnumb = /^\d{4}$/;
\t if (form.one.value == "") {
\t errors += "Please enter your full name! \n";
\t \t }
\t else if (!alph.test(form.one.value)) {
\t errors += "Full name is wrong or includes invalid characters! \n";
\t }
\t if (form.two.value == "") {
\t errors += "Please enter your 16-digit code! \n";
\t }
\t if (!cardnumb.test(form.two.value)) {
\t errors += "Card number does not consist of 16 digits or includes invalid characters! \n";
\t }
\t if (form.three.value == "") {
\t errors += "Please enter your month of expiration! \n";
\t }
\t if (!monthnumb.test(form.three.value)) {
\t errors += "The month does not consist of 2 digits or includes invalid characters! \n";
\t }
\t \t
\t if (form.four.value == "") {
\t errors += "Please enter your year of expiration! \n";
\t }
\t if (!yearnumb.test(form.four.value)) {
\t errors += "The year does not consist of 4 digits or includes invalid characters! \n";
\t }
\t if (form.five.value == "") {
\t errors += "Please enter your 3-digit CVV code! \n";
\t }
\t if (!cvvnumb.test(form.five.value)) {
\t errors += "The CVV does not consist of 3 digits or includes invalid characters! \n";
\t }
\t \t
\t if (!content == "") {
\t \t alert(content);
\t \t return false;
\t \t }
\t }
<!DOCTYPE html>
<html lang="en-US" class="Html" id="Main" dir="auto">
<head class="Head" id="Main">
\t <link rel="stylesheet" type="text/css" href="style.css">
\t <meta name="description" content="NRN">
\t <meta name="author" content="NRN">
\t <title class="Title" id="Title">NRN</title>
</head>
<body class="Body" id="Main">
\t <nav>
\t \t <ul>
\t \t <li><a href="index.html">Home</a></li>
\t \t </ul>
\t </nav>
\t <p class="p1">Payment form validation using JavaScript<p>
\t <form method="POST" action="success.html" class="myForm" name="myForm" onSubmit="javascript:return FormValidation(this)">
\t <div class="form-group-name">
<label for="name">Owner</label><br>
<input type="text" placeholder="Name on card" class="form-control-1" id="one" name="one">
</div>
<div class="form-group-number">
<label for="number">Card number</label><br>
<input type="text" placeholder="16-digit code" class="form-control-2" id="two" name="two">
</div>
<div class="form-group-date">
<label for="date">Expiration date</label><br>
<input type="text" placeholder="Month" class="form-control-3" id="three" name="three">
<input type="text" placeholder="Year" class="form-control-3" id="four" name="four">
</div>
<div class="form-group-cvv">
<label for="cvv">CVV</label><br>
<input type="text" placeholder="3-digit code" class="form-control-4" id="five" name="five">
</div>
<div class="form-group-submit">
<input type="submit" class="submit_form" value="Validate">
</div>
</form>
</body>
</html>
私もすべて、同様に多くのチュートリアルを確認しているが、それは解決しません。助けてください!前もって感謝します! .cssファイルに問題がありますか?
があるでしょうHTML側で
のようなものがあるでしょうフォームのフレームがサンドボックス化されており、 '許可フォーム'のアクセス許可が設定されていません。 – Monicka
コンソールの2番目のエラー:フォームのフレームがサンドボックス化されており、 'allow-forms'権限が設定されていないため、フォームの送信が ''にブロックされました。 – Monicka