且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

服务器站点验证

更新时间:2022-02-23 23:20:10

配合,这是一个基本问题,在发布基本问题之前,应先在搜索引擎中进行搜索.将 Maxlength ="50" 设置为相应的文本框.
Mate, It''s a basic question, you should search in search engines before you posting basic questions. Set Maxlength="50" to that appropriate Textbox.


可以采用多种方法.

1.设置MaxLength(上面已经建议过)
2.使用Javascript跟踪基于onchange/onkeypress事件填充的字符
3.使用正则表达式验证器小心
4.使用Masked文本框(内部实现选项2/3)
There can be various ways to do it.

1. Setting MaxLength (already suggested above)
2. Use Javascript to track the characters filled based on onchange/onkeypress events
3. Use Regular Expression Validators to take care
4. Use Masked textboxes (option 2/3 is internally implemented)


Sandeep是正确的.
有多种方法可以实现.
如果您想使用javascript Heres验证您的用户输入,请使用基本功能

Sandeep is correct.
there are various ways to do it.
if you want to validate your user input using javascript heres a basic function

<script type="text/javascript">

function validate() 
{ 
    if (document.getElementById('txt').value.length > 50) 
    { 
        alert("error message"); return false 
    }
}
</script>


<input type="text" id="txt" />
<input button="submit" onclick="return validate();" />