Click here to Skip to main content
15,904,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
validation should be done without using any Validations controls
i mean form is design as

Textbox1(required Field validation)<br />
textbox2(Email Validation)<br />
Textbox3( Numeric validation)<br />
Textbox4(NO special characters validation)<br />
Textbox5(Alpha numeric validation)<br />
Textbox6(Date validation)



here i need code using java script in asp.net without using any Validation controls to toolbox ........

EDIT
-------------------
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
<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>



i have written code like this but it not working
pls help me i am new for .Net.........
Posted
Updated 14-Nov-11 0:50am
v4

Simple Google search is enough for this question, check this

Javascript Field Validations -- Client Side Scripting[^]
 
Share this answer
 
you need Various Javascripts functions to validate each textboxes.
check following code.

//for Textbox1 - check for empty
JavaScript
function checkEmpty()
{
  if (document.getElementById("Textbox1").value=="")
     {
         alert("Please enter value in textbox1");
         document.getElementById("Textbox1").focus();
         return false;
     }
}


//for Textbox2 - EMail validation
JavaScript
function checkEmpty()
{

filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (filter.test(document.getElementById("Textbox2").value))
     alert ("valid")
  else
     alert ("Invalid")
}



//for Textbox3/5 - check for Numeric and alphanumeric

JavaScript
function checkInt()
{    
    if (isNAN(document.getElementById("Textbox3").value))
	alert("Text is alpha numeric, Please enter only numbers");
}


//for textbox 4 - special char validation

JavaScript
function checkSpecialchar()
{
 var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";

  for (var i = 0; i < document.getElementById("Textbox4").value.length; i++) 
  {
  	if (iChars.indexOf(document.getElementById("Textbox4").value.charAt(i)) != -1) 
        {
  	  alert ("do not enter special char.");
  	  return false;
        }
  }
}


//for textbox 6 - Date validation
JavaScript
function checkSpecialchar()
{
  var date_chk = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;
  if (! reDate.test(document.getElementById("Textbox6").value);) 
  {
     alert ("Invalid date");
     return false;
   }
}


hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900