.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Need Code for Validations Using Javascript without using Validation Controls in ASP.NET

Posted By: Raghu     Posted Date: November 14, 2011    Points:5   Category :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);

}

}
&lt;/script>
&lt;head runat="server">

&lt;title>&lt;/title>

&lt;/head>

&lt;body>
&lt;form id="form1" runat="server">
&lt;form action="javascript.asp?<%--ID=<%=siteID%>--%>"
method="POST" onsubmit="return Form1_Validator(this)" name="Form1">
&lt;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:Label>
<asp:TextBox ID="Name" runat="server"
style="z-index: 1; left: 96px; top: 287px; position: absolute"></asp:TextBox>





&lt;/form>
&lt;/form>
&lt;/body>
&lt;/html>


i have written code like this but it not working
pls help me i am new for .Net.........

Responses
Author: Amit Mehra             
Posted Date: November 16, 2011     Points: 20   

Hi,

I would recommend you to use JQuery validate plugin to validate ASP.Net controls..

You can find the Jquery validate controls here

http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Maverick             
Posted Date: November 18, 2011     Points: 20   

Hello,

Please take care that if the javascript is disabled in your browser the validations won't work. So it is better to use the normal asp.net validators

Thanks,
Maverick


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend