猿问

单选按钮未在多步联系表单中验证

我想验证此表单,但我无法验证这些单选按钮,请帮忙。并且还希望在某些字段错误时显示警报。


/ * 这里是 HTML 代码* /


<form id="regForm" action="/action_page.php">

      <h1>Register:</h1>

      <!-- One "tab" for each step in the form: -->

      <div class="tab">Where do you want to move? *:

        <p><label class="cont">Local

          <input type="radio" name='thing' value='local' data-id="local">

          <span class="checkmark"></span>

        </label>

        <label class="cont">Domestic

          <input type="radio" name='thing' value='domestic' data-id="domestic">

          <span class="checkmark"></span>

        </label>

        <label class="cont">International

          <input type="radio" name='thing' value='international' data-id="international">

          <span class="checkmark"></span>

        </label>

    </p>

      </div>

      <div class="tab">Name:

        <div id="local" class="none">

            <p>

                <label class="cont">1 BHK Goods

                  <input type="radio" name='size' value='1 bhk'>

                  <span class="checkmark"></span>

                </label>

                <label class="cont">2 BHK Goods

                  <input type="radio" name='size' value='2 bhk'>

                  <span class="checkmark"></span>

                </label>

                <label class="cont">3 BHK Goods

                  <input type="radio" name='size' value='3 bhk'>

                  <span class="checkmark"></span>

                </label>

                <label class="cont">4 BHK/Villa Goods

                  <input type="radio" name='size' value='3 bhk'>

                  <span class="checkmark"></span>

                </label>

森栏
浏览 145回答 2
2回答

白衣染霜花

function validateEmail(emailField){&nbsp; &nbsp; &nbsp; &nbsp; var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;&nbsp; &nbsp; &nbsp; &nbsp; if (reg.test(emailField.value) == false)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert('Invalid Email Address');&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; return true;}<p><input type="email" placeholder="From..." oninput="this.className = ''" onblur="validateEmail(this);" name="email" ></p>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答