在不使用ASP.NET中的验证控件的情况下,需要使用Java验证的代码 [英] Need Code for Validations Using Javascript without using Validation Controls in ASP.NET
问题描述
应该在不使用任何验证控件的情况下进行验证
我的意思是形式被设计为
Textbox1(必填字段验证)
textbox2(电子邮件验证)
Textbox3(数值验证)
Textbox4(无特殊字符验证)
Textbox5(字母数字验证)
Textbox6(日期验证)
在这里,我需要在asp.net中使用Java脚本而不在工具箱中使用任何验证控件的代码.....
并给我有关如何在Asp.net中进行操作的信息
我已经尝试了很多,但是我没有得到解决方案,JavaScript代码应该写在哪里,asp.net代码应该写在哪里.它是如何工作的...
validation should be done without using any Validations controls
i mean form is design as
Textbox1(required Field validation)
textbox2(Email Validation)
Textbox3( Numeric validation)
Textbox4(NO special characters validation)
Textbox5(Alpha numeric validation)
Textbox6(Date validation)
here i need code using java script in asp.net without using any Validation controls to toolbox ........
and also give me information how to do in Asp.net
i have try lot but iam not getting solution where javascript code should write and where asp.net code should write. how it works...............
<html xmlns="http://www.w3.org/1999/xhtml">
<script language="javascript">
<!--
function Form1_Validator(theForm)
{
var alertsay = "";
if (theForm1.Name.value == "")
{
alert("You must enter an Name.");
theForm.Name.focus();
return (false);
}
}
</script>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<form action="javascript.asp?<%--ID=<%=siteID%>--%>"
method="POST" onsubmit="return Form1_Validator(this)" name="Form1">
<input type="submit" name="Submit" value="Submit">
<asp:Label ID="Label1" runat="server"
style="z-index: 1; left: 42px; top: 291px; position: absolute"
Text="Label">
<asp:TextBox ID="Name" runat="server"
style="z-index: 1; left: 96px; top: 287px; position: absolute">
</form>
</form>
</body>
</html>
我已经编写了这样的代码,但是它不起作用
请帮助我,我对.Net还是陌生的....
i have written code like this but it not working
pls help me i am new for .Net.........
推荐答案
看看jQuery,它可以帮助您验证用户输入: http://docs.jquery.com/Plugins/Validation [
Take a peek at jQuery, which is able to help you validating user inputs : http://docs.jquery.com/Plugins/Validation[^]
必须将<script>
块写在<head>
内或<body>
标记,您已将其保留在根目录中,这是无效的,将其移至head即可.
如果解决您的问题,则将其标记为答案,这会激发:)...
the<script>
block must be written eighter inside<head>
or<body>
tag, you have kept it in root, which is invalid, shift it to head, it will work.
mark as answer if solves your problem, it motivates :)...
function checkEmpty()
{
if (document.getElementById("Textbox1").value=="")
{
alert("Please enter value in textbox1");
document.getElementById("Textbox1").focus();
return false;
}
}
function checkEmpty()
{
filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+
这篇关于在不使用ASP.NET中的验证控件的情况下,需要使用Java验证的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!