[CLOSED] Custom validator for TextArea

  1. #1

    [CLOSED] Custom validator for TextArea

    Hi,

    I want to have custom validator for "TextArea" control, any example of comments will be highly appriciated.


    
    
    <ext:TextArea ID="emailMessage" HideLabel="true" runat="server"> 
    
    
    </ext:TextArea>

    Thanks
  2. #2

    RE: [CLOSED] Custom validator for TextArea

    Hi,

    Use Validator proeprty. Define javascript function to validate the value and set the name of that function to the Validator property


    validator : Function<div class="mdesc" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 0px; color: rgb(68, 68, 68); "><div class="long" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: 18px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">A custom validation function to be called during field validation (validateValue) (defaults to <tt>null</tt>). If specified, this function will be called first, allowing the developer to override the default validation process.</p>
    <p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">This function will be passed the following Parameters:</p><div class="mdetail-params" style="margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 12px; font-size: 12px; "><ul style="margin-top: 12px; margin-right: 12px; margin-bottom: 12px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: circle; list-style-position: inside; list-style-image: initial; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-position: inside; list-style-type: circle; list-style-image: initial; "><code style="font-style: normal; font-weight: normal; font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: 12px; ">value</code>: Mixed<div class="sub-desc" style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 16px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The current field value[/list]

    <p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">This function is to Return:</p><div class="mdetail-params" style="margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 12px; font-size: 12px; "><ul style="margin-top: 12px; margin-right: 12px; margin-bottom: 12px; margin-left: 12px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: circle; list-style-position: inside; list-style-image: initial; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-position: inside; list-style-type: circle; list-style-image: initial; "><code style="font-style: normal; font-weight: normal; font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: 12px; ">true</code>: Boolean<div class="sub-desc" style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 16px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><code style="font-style: normal; font-weight: normal; font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: 12px; ">true</code> if the value is valid
    <li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-position: inside; list-style-type: circle; list-style-image: initial; "><code style="font-style: normal; font-weight: normal; font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: 12px; ">msg</code>: String<div class="sub-desc" style="margin-top: 5px; margin-right: 5px; margin-bottom: 5px; margin-left: 16px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">An error message if the value is invalid[/list]



  3. #3

    RE: [CLOSED] Custom validator for TextArea

    Hi,

    I tried your suggestion, but I am getting issues:

     
    
    
    function testValidation(value)
    
    { 
    
    // do something
    
    }   
    
    <ext:TextArea ID="emailMessage" HideLabel="true" runat="server" validator="function(value) { testvalidation(value) }" />






    This code is not working and I am getting "Object expected" error. can you please show me some example of using validator for "textArea".

    Thanks</PRE>
  4. #4

    RE: [CLOSED] Custom validator for TextArea

    Hi,

    You have to return true or error message
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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 runat="server">
        <title>Combobox Bug</title>
        
        <script type="text/javascript">
            function myValidator(value){
                if(value !== "Agree"){
                    return "Please write 'Agree'";
                }
                
                return true;
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:TextArea runat="server" Validator="myValidator" Width="300" Height="200" />
        </form>
    </body>
    </html>
  5. #5

    RE: [CLOSED] Custom validator for TextArea

    Thanks, it worked.

Similar Threads

  1. Crazy validator
    By CarWise in forum Bugs
    Replies: 1
    Last Post: Jan 10, 2011, 10:41 AM
  2. [CLOSED] [0.8.2] CheckBox and Validator
    By mrozik in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 09, 2010, 10:34 AM
  3. [CLOSED] [1.0] Equivalent to ASP.NET custom validator
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 24, 2010, 2:10 PM
  4. [CLOSED] textarea with validator
    By jeremyl in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 27, 2010, 10:09 AM
  5. Custom Search on TextArea
    By mj.daly in forum 1.x Help
    Replies: 2
    Last Post: Feb 02, 2010, 9:37 AM

Posting Permissions