验证文本框而不回发 [英] Validating textboxes without postback

查看:70
本文介绍了验证文本框而不回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务器中单击它之前,我有4个服务器控件文本框和一个sumbit asp按钮,如何并且仅当正确填充了asp文本框时,才必须在服务器中传递值,我该如何检查asp文本框是否正确? /> 请帮忙
在此先感谢

I have 4 server control textboxes and a sumbit asp button before hitting it in server how can i check whether the asp textboxes are filled properly or not if and only if it is filled properly the value has to be passed in server
please help
thanks in advance

推荐答案

ASP.Net具有验证控件,您应该在工具箱上看到这些控件.有一些用于验证数字,日期,RegEx,必填项等的方法.或者,您始终可以使用JS.我将从工具箱上的验证控件开始,然后在遇到问题时再返回.
ASP.Net has validation controls that you should see on your ToolBox. There are some for validating nummbers, dates, RegEx, Required, etc. Or, you can always use JS. I would start with the validation controls on the toolbox and then come back if you run into problems.


最好使用文本框的客户端验证.
It is better to use client side validation of text box.


function validate()
{
 var txt1=document.getElementById("<%=txtBox1.ClientID%>");
 if(txt1.value=="")
{
return false;

}
 }

call this function using Button OnClientClick="return validate();"


这篇关于验证文本框而不回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆