Home >Backend Development >PHP Tutorial >javascript 验证空白区域,该怎么解决

javascript 验证空白区域,该怎么解决

WBOY
WBOYOriginal
2016-06-13 10:20:08954browse

javascript 验证空白区域
我的php有个页面 想用js去控制用户少输入一项 会出现提示,该怎么做?
我试过网上给你的代码,不太成功。

比如有个form是这样的:

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->


比如用户没选择性别这一栏,我希望能出现提示,该怎么弄?
如果name="gender" 是动态的,比如 name="gender_" 那又该怎么弄???

很紧急啊!

------解决方案--------------------
下面这样能检查两个都选中,也可能没把需求理解清楚
JScript code

}
<script>function aa(){ var radioInput=document.getElementsByTagName("form")[0].getElementsByTagName("input"); if(radioInput[0].checked==false || radioInput[1].checked==false){ alert("请选择。。"); return false; }}</script>
------解决方案--------------------
探讨

radio的名字是变动的,不一定是payment
引用:


JScript code
function foo(){
var count=0;
var payments=document.getElementsByName('pa……
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn