I see there is a property of the RadMaskedTextBox called RequireCompleteText which will verify the full mask is satisfied. Is there a way to only enable this if a value has been entered? Basically, I want the user to be able to submit the form with either nothing in the field, or the complete text if they decide to enter a value. Right now, an empty field fails the RequireCompleteText validation.
5 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 17 Jul 2014, 04:17 AM
Hi Richard,
Try to attach the OnKeyPress client event and set requireCompleteText property as true.
JavaScript:
Please provide your code if it doesn't help.
Thanks,
Shinu.
Try to attach the OnKeyPress client event and set requireCompleteText property as true.
JavaScript:
function
validateValue(sender, args) {
sender._requireCompleteText =
true
;
}
Please provide your code if it doesn't help.
Thanks,
Shinu.
0

Joel Kraft
Top achievements
Rank 2
answered on 31 Dec 2014, 02:50 AM
Hello,
I have this same question and I'm not quite sure how your answer applies.
Here would be an example markup for the masked textbox:
The input should be acceptable if the box is completely empty, or the entire mask is filled:
Joel
I have this same question and I'm not quite sure how your answer applies.
Here would be an example markup for the masked textbox:
<
TELERIK:RadMaskedTextBox
runat
=
"server"
ID
=
"test"
Mask
=
"###/###-####"
EmptyMessage
=
"(none)"
SelectionOnFocus
=
"SelectAll"
RequireCompleteText
=
"true"
/>
The input should be acceptable if the box is completely empty, or the entire mask is filled:
- (empty)
- 123/456-7890
- 555/555-1212
- 123/___-____
- 123/456-000_
- ___/456-4560
Joel
0
Hi Joel,
Generally when RequireCompleteText is enabled and no text is entered in the input element by default it should prevent submitting the form. Nevertheless you can workaround this behavior by manually change the valid state of the control. For this purpose you can hook OnBlur client event and if the input element is empty to set invalid property to false. Please check out the following code snippet.
Regards,
Kostadin
Telerik
Generally when RequireCompleteText is enabled and no text is entered in the input element by default it should prevent submitting the form. Nevertheless you can workaround this behavior by manually change the valid state of the control. For this purpose you can hook OnBlur client event and if the input element is empty to set invalid property to false. Please check out the following code snippet.
<
script
type
=
"text/javascript"
>
function OnBlur(sender, args) {
if (sender.get_value().length == 0) {
sender.set_invalid(false);
}
}
</
script
>
<
telerik:RadMaskedTextBox
runat
=
"server"
ID
=
"test"
Mask
=
"###/###-####"
RequireCompleteText
=
"true"
SelectionOnFocus
=
"SelectAll"
ClientEvents-OnBlur
=
"OnBlur"
/>
Regards,
Kostadin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Joel Kraft
Top achievements
Rank 2
answered on 05 Jan 2015, 02:46 PM
Personally, I think the required part would be left to the RequiredFieldValidator to be consistent with how other things in the framework, such as the RegularExpressionValidator, work. I can't really think of another instance where empty would be an error in this way.
But the workaround does work fine.
But the workaround does work fine.
0
Hi Joel,
Note that by default RequireCompleteText is implemented to work with RequiredFieldValidator. So generally you have to enabled both of them if you need to work correctly. Otherwise you have to disable RequireCompleteText and use some other validation control.
Regards,
Kostadin
Telerik
Note that by default RequireCompleteText is implemented to work with RequiredFieldValidator. So generally you have to enabled both of them if you need to work correctly. Otherwise you have to disable RequireCompleteText and use some other validation control.
Regards,
Kostadin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.