I want to create a masked number input format like "#####:##"
The first ##### part present the number of hours, and the later "##" part represent the number of mins
The database stores the field in turns of minutes. What I am doing is to calculate the number of hours and place it in the first part, and so as the mins.
I found the masked text box will always place the hour strin on the left of "#####", i.e. Say I have 230 hours and 14 mins, the textbox display it like this: "230__:14".
What I am expecting is : "__230:14", could you suggest what setting is missing?
Thanks,
Michael
The first ##### part present the number of hours, and the later "##" part represent the number of mins
The database stores the field in turns of minutes. What I am doing is to calculate the number of hours and place it in the first part, and so as the mins.
I found the masked text box will always place the hour strin on the left of "#####", i.e. Say I have 230 hours and 14 mins, the textbox display it like this: "230__:14".
What I am expecting is : "__230:14", could you suggest what setting is missing?
Thanks,
Michael
5 Answers, 1 is accepted
0
Michael
Top achievements
Rank 1
answered on 07 Jun 2010, 02:24 AM
Any updates?
0
Hi Michael,
The RadMaskedTextBox does not support the desired functionality, however you could try modifying the RadMaskedTextBox value with javascript. Please try the following code snippet and let me know if it helps you:
Also note that this is not a supported scenario.
Additionally I am sending you a simple example which demonstrates how to achieve the desired functionality.
Kind regards,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
The RadMaskedTextBox does not support the desired functionality, however you could try modifying the RadMaskedTextBox value with javascript. Please try the following code snippet and let me know if it helps you:
<telerik:RadCodeBlock runat=
"server"
>
<script type=
"text/javascript"
>
function
OnValueChanged(sender, eventArgs)
{
var
radmaskedtextbox = $find(
"<%=RadMaskedTextBox1.ClientID %>"
);
var
value = radmaskedtextbox.get_value();
var
valueLength = value.length;
var
firstPaqrtLength = valueLength - 2;
var
firstPart = value.substring(0, firstPaqrtLength);
var
secondPart = value.substring(firstPaqrtLength, valueLength);
var
maskLength = 7;
var
newValue = firstPart + secondPart;
for
(
var
i = 0; i < maskLength - newValue.length; i++)
{
newValue =
" "
+ newValue;
}
radmaskedtextbox.set_value(newValue);
}
</script>
</telerik:RadCodeBlock>
Also note that this is not a supported scenario.
Additionally I am sending you a simple example which demonstrates how to achieve the desired functionality.
Kind regards,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michael
Top achievements
Rank 1
answered on 11 Jun 2010, 08:50 AM
Thanks for the sample.
As I have changed my approach right now. Still have a problem about the validation.
What I am doing is: I placed a radtextbox, a regularexpressionvalidator and a label in the edit template of a radlistview.
In side the itemdatabound, I passed the regex string to the validator, the previous month's value to the label, and the current month's value in the textbox. And also, I will assign the ontextchanged client event to check the difference of my inputed value in the radtextbox and the label's value(previous month's one).
But what troubles me is that the validator is triggered after the ontextchanged client javascript function.
I need to get the validator's attribute changes (validate result) within the ontextchanged client event function. However I have no idea how to achieve it.
The javascript function cannot get the validator by $get(validator.clientid) or document.getElementID('<%=validator.clientid %>'. All returns NULL.
As I have changed my approach right now. Still have a problem about the validation.
What I am doing is: I placed a radtextbox, a regularexpressionvalidator and a label in the edit template of a radlistview.
In side the itemdatabound, I passed the regex string to the validator, the previous month's value to the label, and the current month's value in the textbox. And also, I will assign the ontextchanged client event to check the difference of my inputed value in the radtextbox and the label's value(previous month's one).
But what troubles me is that the validator is triggered after the ontextchanged client javascript function.
I need to get the validator's attribute changes (validate result) within the ontextchanged client event function. However I have no idea how to achieve it.
The javascript function cannot get the validator by $get(validator.clientid) or document.getElementID('<%=validator.clientid %>'. All returns NULL.
0
Michael
Top achievements
Rank 1
answered on 11 Jun 2010, 08:53 AM
Following statement cannot get the textbox object in the javascript function, as the radtextbox or my validator object are placed inside the edit template of the radlistview.
var radmaskedtextbox = $find("<%=RadMaskedTextBox1.ClientID %>");
0
Hello Michael,
You could try finding the RadMaskedTextBox1 on server side and set its ClientID to the javascript variable:
Then on client side you could find the RadMaskedTextBox1 with the following code snippet:
Also please check out the following online example which demonstrates the RadListView validation:
http://demos.telerik.com/aspnet-ajax/listview/examples/dataediting/validation/defaultcs.aspx
All the best,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You could try finding the RadMaskedTextBox1 on server side and set its ClientID to the javascript variable:
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"setID"
,
"RadMaskedTextBox1 = '"
+ RadMaskedTextBox1.ClientID +
"';"
,
true
);
Then on client side you could find the RadMaskedTextBox1 with the following code snippet:
RadMaskedTextBox1 =
""
;
function
DoSomething()
{
var
radmaskedtextbox = $find(RadMaskedTextBox1);
...
}
Also please check out the following online example which demonstrates the RadListView validation:
http://demos.telerik.com/aspnet-ajax/listview/examples/dataediting/validation/defaultcs.aspx
All the best,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.