[CLOSED] Cancel button event if wrong date in datefield

  1. #1

    [CLOSED] Cancel button event if wrong date in datefield


    I have 2 datefield from and to (daterange), and I have 1 button. The button have direct event on it.
    If I inputted wrong date format (when the red line shown in the datefields), and then click the button, I expect to cancel the event on the button and show error message.
    How can I do this?

    I am thinking to use listener for checking and direct method for the event. But how to check if the datefield is in the wrong format?


    <ext:DateField ID="DateField_From" runat="server" EndDateField="DateField_To" Vtype="daterange"></ext:DateField>
    <ext:DateField ID="DateField_To" runat="server" StartDateField="DateField_From" Vtype="daterange"></ext:DateField>
    <ext:Button ID="Button1" runat="server" Text="Button1">
         <Click OnEvent="Button1_Event"></Click>
    Last edited by Daniil; Oct 14, 2011 at 4:25 PM. Reason: [CLOSED]
  2. #2

    To prevent a DirectEvent please return false from a .Before handler of that DirectEvent or the same client side listener.

    To check a DateField (and any other field) on valid (including format), please use the .isValid() method.
  3. #3
    tq Daniil,

    is it possible to move the javascript code to .js file?

    i've tried to move it to separate .js file but it turn out the page cannot be loaded because javascript error
    seem. not recognizing the extjs

    this part is not parsed i think.
    #{DateField_PeriodFrom}.isValid() == false
  4. #4
    Sure, possible.

    If you use an "Ext" reference in that file, please place <script> after ResourcePlaceHolder.
    <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    <script type="text/javascript" src="script.js></script>

Similar Threads

  1. [CLOSED] Wrong JSON Date Timezone ...
    By prointernet in forum 1.x Legacy Premium Help
    Replies: 17
    Last Post: May 22, 2014, 5:22 AM
  2. [CLOSED] Wrong Date Format on the store
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 25, 2011, 9:56 PM
  3. Replies: 3
    Last Post: May 06, 2010, 12:48 PM
  4. Replies: 3
    Last Post: Mar 17, 2009, 9:42 AM
  5. How to cancel DateField change event
    By zikr in forum 1.x Help
    Replies: 4
    Last Post: Jan 16, 2009, 1:31 PM

Posting Permissions