其中文本框右侧已经标注要输入的信息,有的是文字,有的是数字,在用户提交后怎样判断输入框中输入的信息必须为文字或者数字呢,请给段代码谢谢<table align="right" >
    <tr>
     <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10"/>id:</td>
     <td width="300" align="left" class="zhushi"><input type="text" id="text_name1" name="hot" value="">*输入数字</td>
    </tr>
    <tr>
      <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始:</td>
      <td align="left" class="zhushi">
        <input type="text" id="text_name2" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
    </tr>
    <tr>
      <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束:</td>
      <td align="left" class="zhushi">
        <input type="text" id="text_name3" name="end"  onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
    </tr>
    <tr>
     <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>
     <td align="left" class="zhushi">
     <input type="text" id="text_name4" name="sre" value="" >*输入中文</td>
    </tr>
    <tr>
      <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
      <td align="left" class="zhushi"><input type="text" name="s_tp" value="">&nbsp;输入数字</td>
    </tr>
    <tr>
      <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>介绍:</td>
      <td width="388">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
       <textarea name="ctn" id="text_name5" style="width:300px; height:50px;"></textarea>*输入中文
      </td>
    </tr>
    <tr>
      <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
    </tr>
  </table> 

解决方案 »

  1.   


    <table align="right" >
        <tr>
         <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10"/>id:</td>
         <td width="300" align="left" class="zhushi"><input type="text" id="text_name1" name="hot" onkeyup="value=value.replace(/[^0-9]/g,'')"  >*输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name2" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
        </tr>
        <tr>
          <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name3" name="end"  onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
        </tr>
        <tr>
         <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>
         <td align="left" class="zhushi">
         <input type="text" id="text_name4" name="sre" value="" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')">*输入中文</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
          <td align="left" class="zhushi"><input type="text" name="s_tp" value="">&nbsp;输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>介绍:</td>
          <td width="388">&nbsp;</td>
        </tr>
        <tr>
          <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
           <textarea name="ctn" id="text_name5" style="width:300px; height:50px;" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" ></textarea>*输入中文
          </td>
        </tr>
        <tr>
          <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
        </tr>
      </table> onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')"  中文
    onkeyup="value=value.replace(/[^0-9]/g,'')"  数字
      

  2.   

    这段代码为什么不起作用<script type="text/javascript">
    function formcheck()
    {
    if(!IsNum(form.hot.value))
        {
         alert("请输入数字!")
         form.hot.focus();
         return false;
        }
         function IsNum(num)
        {
         var reNum=/[^\d]/g,";
         return(reNum.test(num));
        }}
    </script>
    </head>
    <body>
    <center>
    <form name="form1" action="login.php" method="POST" onsubmit="return Check();">
    <fieldset style="width:400px; ">
     <legend style="color:#8492B5;">添加</legend>
       <table align="right" >
        <tr>
         <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10" name/>id:</td>
         <td width="300" align="left" class="zhushi"><input type="text" id="text_name1" name="hot" value="" onsubmit="reutrn formcheck()">*输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name2" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
        </tr>
        <tr>
          <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name3" name="end"  onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
    </tr>
    <tr>
     <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>
         <td align="left" class="zhushi">
         <input type="text" id="text_name4" name="sre" value="">*输入中文</td>
        </tr>
    <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
          <td align="left" class="zhushi"><input type="text" name="s_tp" value="">&nbsp;输入数字</td>
        </tr>
    <tr>
      <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容介绍:</td>
      <td width="388">&nbsp;</td>
    </tr>
    <tr>
          <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
       <textarea name="ctn" id="text_name5" style="width:300px; height:50px;"></textarea>*输入中文
      </td>
        </tr>
        <tr>
          <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
        </tr>
      </table>
    </fieldset>
    <input type="hidden" name="submit" value="submit">
    </form>
      

  3.   

    把return Check();
    改为:return formcheck();
      

  4.   


    <script type="text/javascript">
    function formcheck()
    {
    if (form1.hot.value=="" || isNaN(form1.hot.value) )
    {
    alert('请输入数字');
    form1.hot.focus();
    return false; 
    }
    var re = /[^\u4E00-\u9FA5]/g; 
    if(re.test(form1.sre.value) || form1.sre.value=="" )
    {
    alert('请输入中文');
    form1.sre.focus();
    return false; 
    }
    return true;
    }
    </script>
    </head>
    <body>
    <center>
    <form name="form1" action="login.php" method="POST" onsubmit="return formcheck();">
    <fieldset style="width:400px; ">
     <legend style="color:#8492B5;">添加</legend>
       <table align="right" >
        <tr>
         <td width="100" height="30" class="wenzi" ><img src="img/38.gif" width="10" height="10" name/>id:</td>
         <td width="300" align="left" class="zhushi"><input type="text" id="text_name1" name="hot" value="" onsubmit="reutrn formcheck()">*输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>开始:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name2" name="start" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
        </tr>
        <tr>
          <td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束:</td>
          <td align="left" class="zhushi">
            <input type="text" id="text_name3" name="end"  onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
        </tr>
        <tr>
         <td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备&nbsp;&nbsp;注:</td>
         <td align="left" class="zhushi">
         <input type="text" id="text_name4" name="sre" value="">*输入中文</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
          <td align="left" class="zhushi"><input type="text" name="s_tp" value="">&nbsp;输入数字</td>
        </tr>
        <tr>
          <td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容介绍:</td>
          <td width="388">&nbsp;</td>
        </tr>
        <tr>
          <td align="left" colspan="2" class="zhushi">&nbsp;&nbsp;&nbsp;&nbsp;
           <textarea name="ctn" id="text_name5" style="width:300px; height:50px;"></textarea>*输入中文
          </td>
        </tr>
        <tr>
          <td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
        </tr>
      </table>
    </fieldset>
    <input type="hidden" name="submit" value="submit">
    </form>