I have Multi RequiredFieldValidators in my Page I want to check validate of one of them using Javascript Function can any one help me
Asked
Active
Viewed 568 times
-1
-
Your question is not clear, What are you trying to do ? enable/disable validation controls ? OR Check validity of controls via JavaScript ??? – yogi Sep 11 '12 at 08:53
-
@yogi : Check validity of controls via JavaScript – Mario Soft Sep 11 '12 at 08:54
-
Means you want to validate a control via JavaScript, If it is so you can use CustomValidator control and write your JavaScript function and provide that function to CustomValidator's ClientValidationFunction. See this http://www.w3schools.com/aspnet/control_customvalidator.asp property. – yogi Sep 11 '12 at 08:57
-
NO mr.@yogi , I have textbox that validate with RequiredFieldValidator , and i want to check if it validate before write some Javascript code , but without check all page validate – Mario Soft Sep 11 '12 at 08:59
-
Hope this will help [http://stackoverflow.com/questions/7640426/why-validatorvalidate-validates-all-the-requiredfieldvalidator-controls-on-the][1] [1]: http://stackoverflow.com/questions/7640426/why-validatorvalidate-validates-all-the-requiredfieldvalidator-controls-on-the – Murali Murugesan Sep 11 '12 at 13:11
2 Answers
1
You can try with validationgroup
on you validator and button submit

Aghilas Yakoub
- 28,516
- 5
- 46
- 51
-
sorry its not i need, I have textbox that validate with RequiredFieldValidator , and i want to check if it validate before write some Javascript code , but without check all page validate – Mario Soft Sep 11 '12 at 09:01
-
In this case you use validationgroup he permits you to separate your validations and not valid all datas – Aghilas Yakoub Sep 11 '12 at 09:05
-
ok but i need to check the RequiredFieldValidator validation with javascript to do somthing with javascript if it valid – Mario Soft Sep 11 '12 at 09:06
-
for your case i recommend you to use CustomValidator because your logic is not adapted to RequiredFieldValidator – Aghilas Yakoub Sep 11 '12 at 09:11
1
Try something like this in your javascript code:
for (i = 0; i < Page_Validators.length; i++) {
if (Page_Validators[i].Errormessage=="your Error message") {
//your code...
}
}
using above code you can differentiate on the basis of your error message.
Or you can try this, but I am not sure if it work or not:
function abc(id){
for (i = 0; i < Page_Validators.length; i++) {
if (Page_Validators[i]==id) {
//your code...
}
}
}
in above code 'id' is the clientid of your particular validator, I am trying to check if two validators are same or not or you can check there equality using any of their unique property to reach your particular validator.