Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在验证中面对的是我选择单选按钮时_Javascript_Php_Mysql_Validation - Fatal编程技术网

Javascript 在验证中面对的是我选择单选按钮时

Javascript 在验证中面对的是我选择单选按钮时,javascript,php,mysql,validation,Javascript,Php,Mysql,Validation,主要问题是,当我选择“现金”单选按钮时,第一个字段必须是必填字段,而如果我选择“第二个按钮”,则支票字段必须是补全字段…… 当我提交验证无效的数据时,为这个程序添加HTML代码 <form action="add_file.php" method="post" enctype="multipart/form-data" name="form4"> <table width="400" align="center" cellspacing="10" &

主要问题是,当我选择“现金”单选按钮时,第一个字段必须是必填字段,而如果我选择“第二个按钮”,则支票字段必须是补全字段……
当我提交验证无效的数据时,为这个程序添加HTML代码

<form action="add_file.php" method="post" enctype="multipart/form-data" name="form4">
              <table width="400" align="center" cellspacing="10" >

      <tr>
        <td></td>

      </tr>
      <tr>
        <td style="width:200px;"><label class="label">Purchase Date:</label></td>
        <td><input type="text" name="Purchase_date" id="datepicker" class="button" /></td>
      </tr>

      <tr>
        <td style="width:200px;"><label class="label">Expanse Head:</label></td>
        <td><input type="text" name="Expanse_head" class="button" /></td>
      </tr>

      <tr>
        <td style="width::200px"><label class="label">Type of Payment:</label></td>
          <td><input type="radio" name="type" value="cash" />
            cash
            <input type="radio" name="type" value="cheque"/><label>
              cheque</label></td>

        </tr>

      <tr>
        <td style="width:200px;"><label class="label">Expanse Cash:</label></td>
        <td><input type="text" name="Expanse_cash" class="button" pattern="[0-9]+" required title="Please Enter Digits"/></td>
      </tr>

       <tr>
        <td style="width:200px;"><label class="label">Cheque No</label></td>
        <td><input type="text" name="cno" class="button" /></td>
      </tr>






        <tr style="margin-top:100px;">
        <td><label class="label">Bill</label></td>
        <td><input type="file" name="uploaded_file"  /></td>

      </tr>
       <tr style="margin-top:100px;">
        <td></td>
        <td><input type="submit" value="Save" onclick="return validate(this);" /></td>

      </tr>
      <tr>
      <td></td>

      </tr>


    </table>


          </form>



    <script>
    function validate(){
    if(document.form4.Purchase_date.value==""){alert("Please Enter Date");  return false;}
    if(document.form4.Expanse_head.value==""){alert("Please Enter Expanse Head");   return false;}

    /*if(document.form4.type.value=="1"){
        (document.form4.Expanse_cash.value=="")
            {alert("Please Enter value");   return false;}}
        else(document.form4.type.value=="cheque")
        {
            (document.form4.cno=="");
            {alert ("Please Enter Cheque No "); return false;}}*/

    if(document.form4.uploaded_file.value==""){alert("Please upload file"); return false;}

        }
    </script>

购买日期:
宽头:
付款类型:
现金
支票
支出现金:
支票号码
比尔
函数验证(){
if(document.form4.Purchase_date.value==“”){alert(“请输入日期”);返回false;}
if(document.form4.Expanse_head.value==”){alert(“请输入Expanse head”);返回false;}
/*if(document.form4.type.value==“1”){
(document.form4.Expanse\u cash.value==“”)
{alert(“请输入值”);返回false;}
else(document.form4.type.value==“支票”)
{
(document.form4.cno==”);
{提醒(“请输入支票编号”);返回false;}*/
if(document.form4.upload_file.value==“”){alert(“请上载文件”);返回false;}
}

重写代码,希望这能奏效

如果(document.form4.type.value==“现金”){

如果(document.form4.Expanse\u cash.value==“”){

}

}

如果有其他情况(document.form4.type.value==“支票”){

如果(document.form4.cno.=“”){

}

否则{

警告(“请选择付款方式!!”


}

你能同时显示你的
HTML
代码吗???因为我不能理解你的控件(对象)的名称!!!所以你没有得到答案…我告诉过你显示你的
HTML
代码!!!
alert("Please Enter value");
return false;
alert ("Please Enter Cheque No "); 
return false;}