本文介绍了检查表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嗨! 我有问题。 上线时一切正常!1!如果 声明,只是单一输入。放&&之后的原因脚本不起作用? <!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN"> < HTML> < HEAD> 功能checkAns(表格) { var radiock; for(var i = 0; i< form.radio1.length; i ++) { if(form .radio1 [i] .checked) { radiock = form.radio1 [i] .value; } } if((form.forename.value =="")&&(radiock == null))/ *!1! * / { 提醒(请回答所有强制性问题!); 返回false; } 其他 { 返回true; } } < / script> < / HEAD> < BODY> < form name =" myform"方法= QUOT;获得" onsubmit =" return checkAns(this);"> < P> 输入你的名字(必填):< input type =" text" size =" 40" name =" forename"> < br> < br> fav color(必填)? < br> < INPUT TYPE =" radio" NAME ="收音机1" VALUE =" red"> red< / P> < P> < INPUT TYPE =" radio" NAME ="收音机1" VALUE =" blue"> blue< / P> < P> < INPUT TYPE =" radio" NAME ="收音机1" VALUE =" green"> green< / P> < P> < INPUT TYPE =" radio" NAME ="收音机1" VALUE =" white"> white< / P> < P> 婚姻状况< INPUT TYPE ="复选框"名称= QUOT;婚姻" value ="">< / P> < P> 任何其他评论< TEXTAREA NAME =" comment" ROWS = QUOT; 5英寸COLS =" 15" WRAP =" physical">< / TEXTAREA> < / P> < P> < INPUT TYPE =" submit" NAME =" NAME" VALUE = [提交" ID =" Submit1"> < / P> < / BODY> < / HTML> 任何想法? - BremseHi!I''ve got problem.Everything works fine when on line !1! is just single entry in ifstatement. Why after putting "&&" script doesn''t work?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD>function checkAns( form ){var radiock;for(var i = 0; i < form.radio1.length; i++){if( form.radio1[i].checked ){radiock = form.radio1[i].value;}}if( (form.forename.value == "") && (radiock == null) ) /* !1! */{alert("please answer all compulsory questions!");return false;}else{return true;}}</script></HEAD><BODY><form name="myform" method="get" onsubmit="return checkAns(this);"><P>Input your name(compulsory): <input type="text" size="40"name="forename"><br><br>fav colour(compulsory)?<br><INPUT TYPE="radio" NAME="radio1" VALUE="red">red</P><P><INPUT TYPE="radio" NAME="radio1" VALUE="blue">blue</P><P><INPUT TYPE="radio" NAME="radio1" VALUE="green">green</P><P><INPUT TYPE="radio" NAME="radio1" VALUE="white">white</P><P>marital status <INPUT TYPE="checkbox" name="marital" value=""></P><P>any other comments <TEXTAREA NAME="comment" ROWS="5" COLS="15"WRAP="physical"></TEXTAREA></P><P><INPUT TYPE="submit" NAME="NAME" VALUE="submit" ID="Submit1"></P></BODY></HTML>any ideas?--Bremse推荐答案 希望能解决您的问题! PhilHope that solves your problem!Phil 玩得开心...... - - FredHave fun...--Fred [...] 表格也必须有一个动作,即使它是" < input .... action ="">[...] forms also must have an action, even if it''s "" <input .... action=""> 应该是: < form .... action =""> 不完美的乐趣。 - Fredand that should have been:<form .... action="">The joys of imperfection.--Fred 这篇关于检查表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-31 23:42