您的位置:程序门 -> web 开发 -> php



php判断表单是否为空的js怎么不管用呢?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


php判断表单是否为空的js怎么不管用呢?[已结贴,结贴人:applejuzi]
发表于:2007-09-21 12:42:10 楼主
代码如下:

<html>

<head>
<meta   http-equiv= "content-type "   content= "text/html;   charset=iso-8859-1 ">
<meta   name= "author "   content= " ">
</head>
<script   language= "javascript ">
function   checkdata()
{
    first=document.myform.txt_fname.value;
    if(first==null)
    {
      alert( "is   null! ");
        return   false;
    }
}
</script>

<body>
<form       action= "res.php "   method= "post "   name= "myform "   onbsumit= "return   checkdata(); ">
<table   align= "center "   width= "500px "   border= "1 ">
<tr> <td> first </td> <td> <input   type= "text "   name= "txt_fname "> </td> </tr>
<tr> <td> last </td> <td> <input   type= "text "   name= "txt_lname "> </td> </tr>
<tr> <td> position </td> <td> <input   type= "text "   name= "txt_position "> </td> </tr>
<tr> <td> address </td> <td> <textarea   rows= "4 "   name= "txt_address "> </textarea>
<tr> <td   colspan= "2 "   align= "center "> <input   type= "submit "   value= "query "> &nbsp;&nbsp; <input   type= "reset "> </td> </tr>
</table>
</form>
</body>
</html>
发表于:2007-09-21 12:51:081楼 得分:8
<form   action= "res.php "   method= "post "   name= "myform "   onbsumit= "return   checkdata(); ">   //onsubmit   拼写有误
发表于:2007-09-21 12:58:482楼 得分:5
<html>

<head>
<meta   http-equiv= "content-type "   content= "text/html;   charset=iso-8859-1 ">
<meta   name= "author "   content= " ">
</head>
<script   language= "javascript ">
function   checkdata()
{
first=document.myform.txt_fname.value;
if(first==null   ¦ ¦   first== ' ')
{
alert( "is   null! ");
return   false;
}
else
document.myform.submit();
}
</script>

<body>
<form   action= "res.php "   method= "post "   name= "myform ">
<table   align= "center "   width= "500px "   border= "1 ">
<tr> <td> first </td> <td> <input   type= "text "   name= "txt_fname "> </td> </tr>
<tr> <td> last </td> <td> <input   type= "text "   name= "txt_lname "> </td> </tr>
<tr> <td> position </td> <td> <input   type= "text "   name= "txt_position "> </td> </tr>
<tr> <td> address </td> <td> <textarea   rows= "4 "   name= "txt_address "> </textarea>
<tr> <td   colspan= "2 "   align= "center ">
<input   type= "button "   value= "query "   onclick= "checkdata() ">
&nbsp;&nbsp; <input   type= "reset ">
</td> </tr>
</table>
</form>
</body>
</html>
发表于:2007-09-21 15:33:093楼 得分:0
hehe,肯定哪里拼错了
发表于:2007-09-21 16:53:254楼 得分:5
onbsumit= "return   checkdata(); ">
onsubmit
发表于:2007-09-21 17:39:595楼 得分:0
多谢大家了,晚上再试试吧。
发表于:2007-09-21 18:01:576楼 得分:2
拼写错误是所有程序员必犯的错误
o(∩_∩)o...哈哈
发表于:2007-09-22 19:02:167楼 得分:0
要注意单词的拼写
呵呵`````````
发表于:2007-10-06 20:38:298楼 得分:0
呵呵,路过,学习一下,正在研究php和js之间的变量传值呢。


快速检索

最新资讯