You are on page 1of 3

<title></title> <script type = "text/javascript"> function S() { alert(document.

getElementById("MainContent_txtName")); } </script> </head> <body> <form id="form1" runat="server"> <div> <p>

<asp:Label ID="lblName" runat="server" Text="Name" Font-Bold="True" Font-Italic="True" Height="22px" Font-Names="Mistral" Font-Size="X-Large" Font-Underline="False" ForeColor="#339966" BorderStyle="None" Width="231px"></asp:Label> </p> <p> <input type="text" onfocus="calibri" onblur="Algerian"/> <asp:TextBox ID="txtName" runat="server" Height="38px" Width="139px" ondatabinding="txtName_DataBinding" ondisposed="txtName_Disposed" oninit="txtName_Init" onload="txtName_ Load" onprerender="txtName_PreRender" ontextchanged="txtName_TextChanged" onunload="txtName_Unload" BackColor="White" BorderColor="#CCFFFF" BorderStyle="Outset" BorderWidth="6px" EnableTheming="True" Font-Bol d="True" Font-Italic="True" Font-Overline="False" Font-Size="Large" Font-Strikeout="False" Font-Underline="False" ForeColor="#003399" CausesValidation="True" EnableViewState="False"

AutoPostBack="True"> </asp:TextBox> </p> <p> <asp:Button ID="btnHello" runat="server" onclick="btnSayHello_Click" Text=" Hello" Width="97px" style="color: #CC0066" Font-Bold="True" Font-Italic="True" Font-Names="Monotype Corsiva" Font-Size="Large" BorderStyle="Dashed" /> </p> </div> </body> </html> <title>(type a title for your page)</title> <script type="text/javascript"> function change_case() { document.form1.type.value = document.form1.type.value.toUpperCase(); } </script> </head> <body onload="form1.type.focus();"> <form name="form1" method="post " action=''''> <input type="text" name="type" value="Enter user id" onblur="change_case();"/> <input type="submit" value="Submit"/> </form> </body> </html> entering numbers in a text: 1.if (form1.TextBox1.Length < 3) { alert("Please enter atleast 3 numbers"); theForm.TextBox1.focus(); return (false); } var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234 56789"; var checkStr = theForm.TextBox1.value;

var allValid = true; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { allValid = false; break; } } if(!allvalid) { alert("Enter special characters"); theForm.TextBox1.focus(); return (false); }

2.<script type="text/javascript"> function Form1_Validator(theform) { var no = document.getElementById("<%= TextBox1.ClientID %>").value.char CodeAt(0); alert(no); if (!((no > 64 && no < 89) (no > 96 && no < 123))) { alert("only letters allowed") } } </script>

You might also like