我希望在必填字段为空的情况下禁用HTML中的按钮。下面给出的代码是按钮所在的形式:
<form>
Name*: <input type="text" size="20" name="name" /> <br /><br /> Surname: <input type="text" size="20" name="sur_name" /> <br />
<br /><br /> Mobile number: <input type="tel" size="15" name="mob" /> <br /><br /> E-mail id*: <input type="Email" size="30" name="user_id" /> <br /><br /> Password*: <input type="Password" size="30" name="pw1" /> <br /><br /> Confirm Password*: <input
type="password" size="30" name="pw2" /> <br /><br /><br /><br /> I accept the terms and conditions <input type="checkbox" name="t&c" /><br /><br />
<input type="submit" class="btn btn-lg btn-primary" value="Sign up now" onclick=window.location.href="https://www.google.co.in/signup" />
</form>
&#13;
表单实际上是一个虚拟注册屏幕,但屏幕重定向是一个404错误屏幕,但我希望如果某些字段为空则禁用该按钮,并且如果密码的两个值是,则重新加载页面不同。
我完全不了解JS,所以请编辑代码以便参数清晰。
答案 0 :(得分:0)
将<input type="text" size="20" name="name" />
替换为<input type="text" size="20" name="name" required/>
将<input type="Email" size="30" name="user_id" />
替换为<input type="Email" size="30" name="user_id" required/>
将<input type="Password" size="30" name="pw1" />
替换为<input type="Password" size="30" name="pw1" required/>
将<input type="password" size="30" name="pw2" />
替换为<input type="password" size="30" name="pw2" required/>