This is a migrated thread and some comments may be shown as answers.

Display warning on invalid entry

2 Answers 28 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Merlin
Top achievements
Rank 1
Merlin asked on 26 Feb 2013, 02:20 AM
Hi,

I am using a RadDatepicker in my form. I want to display a warning near the RadDatePicker if some invalid character is entered?

Thank you,
Merlin.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 26 Feb 2013, 09:21 AM
Hi Merlin,

I guess you want to display a warning icon inside the Textbox of RadDatePicker when the user type some invalid character. Please have a look at the following code in which a warning is shown inside the TextField when the user press any alphabetic keys.

ASPX:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" onKeyPress="return checkInput(event);"
    onKeyDown="return checkInput(event);">
</telerik:RadDatePicker>

JavaScript:
<script type="text/javascript">
    function checkInput(event) {
        var DatePicker = $find("<%= RadDatePicker1.ClientID %>");
        if (event.keyCode >= 65 && event.keyCode <= 90) {
            //checking if the key pressed is an alpahbetic key
            DatePicker.get_dateInput()._invalid = true;
            DatePicker.get_dateInput().updateCssClass();
            //For not showing the alphabet in the textbox and display the warning.
            return false;
        }
        else {
            DatePicker.get_dateInput()._invalid = false;
            DatePicker.get_dateInput().updateCssClass();
            return true;
        }
    }
</script>

Thanks,
Princy
0
Merlin
Top achievements
Rank 1
answered on 26 Feb 2013, 01:43 PM
Thanks for the sample code. I made a little modification and got it working as expected.
Tags
Calendar
Asked by
Merlin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Merlin
Top achievements
Rank 1
Share this question
or