Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
Validating Dates in igDatePicker
posted

Could you please provide a sample code for validate date I mean if user entered wrong date format it simply show an error...

currently I have used code....

$("#signDate").igDatePicker({
width: "180px",
dataMode: "date",
datepickerOptions: {
changeYear: true,
changMonth: true,
minDate: new Date(1900, 01, 01),
maxDate: new Date(2100, 01, 01),
},
placeHolder: "Signed Date"
});

and i want to full validation may be solved by 2 ways...

1. user not able to enter manually...

2. proper validation of wrong datetype

Thanks

Pankaj

Parents
No Data
Reply
  • 10685
    Offline posted

    Hello Pankaj, 

    Thank you for posting in our community! 

    The following are the available inbuilt options to use for validation with igDateEditor: 

    In case you want to restrict the user for doing particular keyboard input, consider using includeKeys option to filter the desired input.  “Gets ability to enter only specific characters in input-field from keyboard and on paste.” 

    To completely restrict user input, you can use disabled option  “Gets/Sets the disabled attribute for the input. If set to true the input is disabled, and all buttons and interactions are disabled. On submitting the form the editor belongs to, the value is not submitted.”

    In case you want to have errors being shown, you can  consider using the igValidator, respectively the igDateEditor validatorOptions  “Note: Validation rules of igValidator, such as min and max value/length are applied separately triggering errors, while the corresponding options of the editor prevent values violating the defined rules from being entered.”

    You will find more details how to use the igValidator at:

    https://www.igniteui.com/help/igvalidator-overview
    https://www.igniteui.com/help/igvalidator-validation-rules

    Additional Related options:
    revertIfNotValid  “Gets/Sets if the editor should revert it's value to the previously valid value in case the value on blur, or enter key is not valid. If the option is set to false, editor calls clear functionality.” 

    I expect the above API will be sufficient for you to implement your requirements.

Children