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

Causesvalidation

5 Answers 114 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 02 Sep 2010, 07:58 PM
Hi..
I have a radcombox box in an ajax panel..
The Causesvalidation does not fire unless I set AutoPostBack to true.
Is this correct....?
I need to validation to fire but I don't want to post back.
thanks again

5 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 03 Sep 2010, 02:27 PM
Hello Jon,

That is correct, validation only fires if the control posts back, at least in the case when you use a CustomValidator control to do validation. Also, I don't quite understand your issue, do you want validation to occur on the combobox when a different item is selected or do you want validation on the rest of the form to be validated based on the selection made in the combobox. If you could expand on what you want to do or show us a simple version of your page.

I hope that helps.
0
Jon
Top achievements
Rank 1
answered on 03 Sep 2010, 02:31 PM
The problem is I have a huge form.. and I dont' wanto postback to validate a the combobox... because on postback.. I change the current control focus and do other stuff....   I'm not a javascript guy and don't know how to write client side validation code (Convert my custom validator regularexpressions to JS)
thanks
0
T. Tsonev
Telerik team
answered on 07 Sep 2010, 04:06 PM
Hi Jon,

What is the expression that you're using. Perhaps we can help you with the conversion.

Sincerely yours,
Tsvetomir Tsonev
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
Jon
Top achievements
Rank 1
answered on 07 Sep 2010, 05:37 PM
Thanks...

 

 

<asp:RegularExpressionValidator ID="valEMAIL" runat="server"

 

 

 

ControlToValidate="txtEMAIL" ErrorMessage="* Improperly formatted Email address"

 

 

 

Font-Bold="False" ForeColor="Red" SetFocusOnError="True"

 

 

 

ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

 

 

 

Display="Dynamic"></asp:RegularExpressionValidator>

 



0
Kalina
Telerik team
answered on 13 Sep 2010, 11:36 AM
Hello Jon,

In fact ASP.NET validators can be fired at client-side with the ValidatorValidate method.
You can handle OnClientBlur RadComboBox event (and optionally  OnClientSelectedIndexChanged event) and fire the RegularExpressionValidator in this manner:
function OnClientBlurHandler(sender, eventArgs) {
    var regularExpressionValidator = document.getElementById('<%= valEMAIL.ClientID %>');
    ValidatorValidate(regularExpressionValidator);
     
    var requiredFieldValidator = document.getElementById('<%= RequiredFieldValidator1.ClientID %>');
    ValidatorValidate(requiredFieldValidator);
}

Additionally – please change the regular expression that you use from:
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
to:
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

I prepared for you a sample page in order to illustrate this approach – please find it attached.

Best wishes,
Kalina
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
ComboBox
Asked by
Jon
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Jon
Top achievements
Rank 1
T. Tsonev
Telerik team
Kalina
Telerik team
Share this question
or