Code Snippet
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
- <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
- TagPrefix="cc1" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- <title></title>
- <script type="text/javascript">
- function Validation() {
- var text = document.getElementById('txt1').value;
- if (text == "") {
- alert('Name Cannot be empty');
- document.getElementById('txt1').focus();
- return false;
- }
- test()
- }
- function test() {
- var a = $find("Editor1");
- var value = a.get_content();
- if (value == "") {
- $get("result").innerHTML = "Editor's content is empty";
- alert('Editor Cannot be empty');
- return false;
- }
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:ScriptManager ID="ScriptManager1" runat="server" />
- Name:<asp:TextBox ID="txt1" runat="server"></asp:TextBox>
- <br />
- <cc1:Editor ID="Editor1" runat="server" Width="300" Height="300" ValidationGroup="Editor" />
- <br />
- <span id="result"></span>
- <br />
- <asp:Button ID="Button1" runat="server" Text="Submit" OnClientClick="return Validation();"
- CausesValidation="true" ValidationGroup="Editor" />
- </div>
- </form>
- </body>
- </html>
0 comments:
Post a Comment