今天把PHP程序與smarty完善了下,現在發過來大家給點建議!分別是模板中加了JS判斷

以下是程序部分代碼

以下是模板部分代碼大家可以看下

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
{literal}
<SCRIPT language=JavaScript>
<!--
function checkform()
{

    if (addnew.name.value=="") {
              alert("請輸入用戶名!");
              addnew.name.focus();             
                  return (false);
  }
    if (addnew.pass.value=="") {
              alert("請輸入密碼!");
              addnew.pass.focus();             
                  return (false);
  }
  if(addnew.pwd2.value==""){
alert("請輸入您的確認密碼!");
document.addnew.pwd2.focus();
return false;
}
 
if(addnew.content.value=="")
{
alert("請輸入內容介紹!");
document.addnew.content.focus();
return false;
}
  return true;
}
//-->
</SCRIPT>
{/literal}
<form name="addnew" id="form1" method="post" action="" οnsubmit="return checkform()">
{strip}
<table border="1" align="center" width="50%">
<tr>
<td>用戶名:</td>
<td><input type="text" name="name" size="30"></td>
</tr>
<tr>
<td>密碼:</td>
<td><input type="password" name="pass" size="30"></td>
</tr>
<tr>
<td>密碼確認:</td>
<td><input type="password" name="pwd2" size="30"></td>
</tr>

<tr>
<td>註冊郵箱:</td>
<td><input name="mail" type="text" size="30"></td>
</tr>
<tr>
<td>詳細介紹</td>
<td><textarea rows="10" cols="40" name="content"></textarea></td>
</tr>
<tr><td colspan="2"><input  type="submit" value="用戶提交" name="submit"></td></tr>
</table>
{/strip}
</form>
</body>
</html>

在模板代碼中分別假如了{literal}{/literal} 與{strip}{/strip}大家可以看下,嘿嘿!提點寶貴意見,我是新手!

發佈了29 篇原創文章 · 獲贊 0 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章