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

Set isValid to RegExpTextBoxSetting in runtime

7 Answers 75 Views
Input
This is a migrated thread and some comments may be shown as answers.
rachel
Top achievements
Rank 1
rachel asked on 05 Oct 2010, 05:36 PM

Hello,

Is there way to set to specific RegExpTextBoxSetting IsValid true or false in runtime myself?
I want to see the error message of the RegExpTextBoxSetting in specific cases.
Is it possible? or the RegExpTextBoxSetting display the error message only by the regular expression ?

Thanks.

7 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 08 Oct 2010, 09:28 AM
Hi Rachel,

You can wire the client side event OnValidating of the RegExpTextBox setting and perform your custom check there. If you decide that the value is invalid, you can use the following code:
function validating(sender, eventArgs) {
  var tb = $find("<%= RadInputManager1.ClientID %>").get_targetInput("<%= TextBox1.ClientID %>");
  //perform your custom check
  if (tb.get_value().indexOf('9') < 0) {
      tb.get_owner()._inputs[tb._id]._invalid = true;
      tb.updateCssClass();
      e.preventDefault();
}

I hope this helps.

Greetings,
Tsvetina
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
rachel
Top achievements
Rank 1
answered on 11 Oct 2010, 03:08 PM
The code you sent  is working good. when i set invalid - the textbox get the red color but, the ErrorMessage not display !
in addition,  there is no preventDefault method to the eventArgs !

0
Tsvetina
Telerik team
answered on 13 Oct 2010, 11:19 AM
Hello Rachel,

You could try by setting the text manually, using set_value() method on the textbox.

As for the preventDefault(), firstly, please note that I had a name mismatch in my code, as my event arguments are declared first as eventArgs, then I call the method on e. Apart from that, preventDefault() is a javascript method that is always applicable on cancellable events, and OnValidating is such, so it should be available for you to call.

Kind regards,
Tsvetina
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
gila
Top achievements
Rank 1
answered on 14 Oct 2010, 09:27 PM
Hello.
I'd like to share whith our code so maybe u will be able to point where the problem is.
We are creating a custom control for regular expression, and now we created custom control for identity. validation of identity we check in JS function we have built so we needed that the valid of our control will be changed against the return value of our function.
We use textbox. refexptextboxsetting. targetinput and radinputmanager.
we add the regexp :

regExpTextBoxSetting.ClientEvents.OnValidating = REG_EXP_ON_VALIDATING_EVENT_HANDLER;

//consts of the name of function

and then in global func which adds the script to the creation of the control we have written:

function validating(sender, args) {

var tb = $find('"

 

+ radInputManagerClientId + @"').get_targetInput('" + textBoxClientId + @"');

 

//perform your custom check

txtIdentity = document.getElementById('"

 

+ textBoxClientId + @"');

 

var retVal=ValidateTZ(txtIdentity.value);

if(retVal==false){

 

tb.get_owner()._inputs[tb._id]._invalid = true;

tb.updateCssClass();

args.preventDefault();

}

}


errors:
1. args-doesnt have the methos preventdefault.
2. we see no change of the control. even if the ret value was false.

thanks a lot!
0
Tsvetina
Telerik team
answered on 20 Oct 2010, 08:46 AM
Hello,

Even if you do not use the preventDefault() method, if you manage to get hold of the RadInputManager and the textbox that it validated, you should still be able to set the invalid style to the textbox. I am attaching a sample application demonstrating that. Please, make sure that you get the correct reference to your RadInputManager.

Best wishes,
Tsvetina
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
gila
Top achievements
Rank 1
answered on 21 Oct 2010, 04:44 AM
Hello,
thanks for your answer, but actually i don't see any change between the solution u have sent me to the code i have written in the previous reply.
When running in debug, i get in the last if statement, and see how it puts invalid to my radinput manager, but nothing happens on screen.

thanks for any help,
gila.
0
Tsvetina
Telerik team
answered on 22 Oct 2010, 03:33 PM
Hi Gila,

The project which I attached does apply the invalid style visually on the textbox on my side. Could you please run the project as it is and see how it behaves? If it works on your side, too,  try to make the needed modifications in order for it to start replicating the issue which you encounter and send the full source back to us, so we can see what causes the issue on your side.

Another option would be to open a formal support ticket and send a runnable version of your project for us to debug locally and make the needed changes, so that it behaves as expected.

Best wishes,
Tsvetina
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
Tags
Input
Asked by
rachel
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
rachel
Top achievements
Rank 1
gila
Top achievements
Rank 1
Share this question
or