Results 1 to 4 of 4

Thread: Datefield validation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    8
    Vote Rating
    0
      0  

    Default Answered: Datefield validation

    Hello,

    I have a datefield on my form. Right now, my date field allows me to type random text/numbers. Is there a way I could force the user to type/select only date in that field. Looking for something similar to forceSelection on a combobox. Please advise.

    Thank you.

  2. For masking the datefield, you need to create a custom vtype and provide it with a regular expression which container permissible characters as per your date format.


    Though, just to share that if a user enters values as random text/numbers in a datefield, then that fields is marked as invalid by default, and also the form does not get submitted (provided you have used form.isValid() check before form submission). This way user can get to know that she has typed in wrong characters.


    In force selection too, a user is allowed to type in a value, though, on blur, that value is validated against the store and removed if not existing.


    Similarly, you can also do the same in datefield by calling a function on blur event and validate the date and remove it if format is wrong.

  3. #2
    Sencha User
    Join Date
    Feb 2011
    Posts
    174
    Answers
    10
    Vote Rating
    2
      0  

    Default

    For masking the datefield, you need to create a custom vtype and provide it with a regular expression which container permissible characters as per your date format.


    Though, just to share that if a user enters values as random text/numbers in a datefield, then that fields is marked as invalid by default, and also the form does not get submitted (provided you have used form.isValid() check before form submission). This way user can get to know that she has typed in wrong characters.


    In force selection too, a user is allowed to type in a value, though, on blur, that value is validated against the store and removed if not existing.


    Similarly, you can also do the same in datefield by calling a function on blur event and validate the date and remove it if format is wrong.

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    8
    Vote Rating
    0
      0  

    Default

    Thanks Netemp, that really helped. Here is what I did.

    onBlur: function () {
    if (!this.isValid()) {
    this.setValue('');
    }
    }

  5. #4
    Sencha User
    Join Date
    Aug 2016
    Posts
    1
    Vote Rating
    0
      0  

    Default Please help regarding my date time problem:

    When I choose any date in date field, it should display the selected date with current time.
    For Example,
    23-Aug-2013 19:25:41
    Can you please someone tell me how it can be done?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •