當前位置:首頁 » 網頁前端 » 前端表單長度有限制嗎
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

前端表單長度有限制嗎

發布時間: 2022-09-04 02:02:12

❶ html, php , js 想用驗證一個表單,當輸入長度超過限制以後,自動提醒長度超過限制。 或

input 有個 maxlength屬性 可以指定文本框的最大長度。


如果用戶是會玩的,想用F12篡改頁面元素 輸入更多字元(這種滲透行為了算是) 直接在表單提交給的php腳本程序頁面中 直接 刪除掉多餘的字元就行了


你要是非要矯情 的話 建議用jQuery 驗證


非常簡單

<input id="username" type="text" maxlength=12 / >


同時在頁面的script部分加入

<scripttype="text/javascript">
$(document).ready(function(){
$("input#username").keyup(function(){
if($("input#username").val().length>=12){
alert('最多隻能輸入12個字元')///這里你換成其他更友善的提示調用函數什麼的都行
}
});
});
</script>

嗯 別忘了 引用jq庫

❷ Post 提交,參數長度有限制嗎

正常情況下POST的長度絕對夠用,伺服器可以對POST做限制,比如apache 搭配PHP就可以限制在16M、IIS的限制絕對夠用
本身沒有限制,只是伺服器會限制,可以配置

❸ 在htmlvalue有長度限制嗎

限制input文本框的輸入長度的話可以為其加上maxlength屬性來限制:
<input type="text" maxlength="6" />
如果是限制input的顯示長度的話,可以直接用CSS中的width來限制:
<input type="text" style="width:180px" />

❹ html 中的表單怎麼控制其長度

1. 長度限制
<script>
function test()
{
if(document.a.b.value.length>50)
{
alert("不能超過50個字元!");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"></textarea>
<input type="submit" name="Submit" value="check">
</form>
~~~~~~~~~~~
表單項輸入數值/長度限定

<script language="javascript">
<!--
function CheckForm()
{
if (document.form.count.value > 100 || document.form.count.value < 1)
{
alert("輸入數值不能小於零大於100!");
document.form.count.focus();
return false;
}
if (document.form.MESSAGE.value.length<10)
{
alert("輸入文字小於10!");
document.form.MESSAGE.focus();
return false;
}
return true;
}
//-->
</script

❺ html表單中輸入字元的最小長度是多少

html表單中輸入字元的最小長度是1個字元。

用input text標簽的maxlength屬性即可實現,代碼如下:

  • <inputtype="text"maxlength="XX"/>

maxlength 屬性後面設置需要限制的欄位長度即可。

前端限制郵箱長度

是限制的。
郵件參數一般需要配置如用戶名、密碼、郵件地址,顯示名稱,以及其他郵件所需的必要配置,一般我們可以通過界面管理的方式進行常規的參數配置。
前端表單內容不能為空,兩次注冊密碼必須一致,電話號碼必須為11位,郵箱限制格式。

❼ php,htm,怎麼限製表單長度、內容

一般來說,這種功能編寫js代碼來完成效果好於用php編寫,以下是一個相對比較完整的用戶注冊示例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注冊</title>
<script language="javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}
}
}
function validate_username(field,alerttxt)
{
with (field)
{
apos=value.length

if (apos<6||apos>12)
{alert(alerttxt);return false}
else {return true}
}
}
function validate_pass(field,alerttxt)
{
with (field)
{
apos=value.length

if (apos<6||apos>10)
{alert(alerttxt);return false}
else {return true}
}
}
function validate_form(thisform)
{
with (thisform)
{

if (validate_required(username,"用戶名不能為空!")==false)
{fname.focus();return false}
if (validate_required(password,"密碼不能為空!")==false)
{Password.focus();return false}
if (validate_pass(password,"密碼不能小於6位或大於10位!")==false)
{password.focus();return false}
if (validate_username(username,"用戶名不能小於6位或大於10位!")==false)
{username.focus();return false}
}
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" onsubmit="return validate_form(this)" action="reg.php">
<table width="344" height="136" border="0" align="center" cellpadding="2" cellspacing="2">
<td width="55" height="35" align="right">用戶:</td>
<td width="275"><input type="text" name="username" id="username" width="150" /></td>
</tr>
<tr>
<td align="right">密碼:</td>
<td height="35"><input type="password" name="password" id="password" width="150" /></td>
</tr>
<tr>
<td height="45" colspan="2" align="center"><input type="submit" value="注冊" /> </td>
</tr>
</table>
</form>
</body>
</html>

❽ html 提交表單 數據限制問題

不清楚,我也想學習呢!