customvalidator

Spring 3.1 Autowiring does not work inside custom constraint validator

让人想犯罪 __ 提交于 2019-11-30 07:07:24
I have an issue with bean autowiring inside a custom constraint validator. A constraint validator instance is not given using Spring's LocalValidatorFactoryBean. The JSR-303 provider is hibernate-validator 4.2.0.Final. Spring configuration excerpt : <!-- JSR 303 validation --> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /> <bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor"/> Custom Constraint Validator: import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext;

asp.net custom validator not firing for textbox

匆匆过客 提交于 2019-11-30 00:12:30
问题 I have both a required field validator and custom validator for validating a texbox. The required field validator fires perfectly. I'm not able to get the custom validator to fire properly? <asp:TextBox ID="txtPRI" runat="server" Width="295" /><br /> <asp:RequiredFieldValidator display="Dynamic" CssClass="leftAlign" SetFocusOnError="true" runat="server" controltovalidate="txtPRI" errormessage="Please enter your PRI" /> <asp:CustomValidator runat="server" id="cusCustom" controltovalidate=

ASP.NET Custom Validator Error Message: Control referenced by the property cannot be validated

独自空忆成欢 提交于 2019-11-29 09:14:37
I use ASP.NET and have a Button and a CustomValidator, which has to validate the button. <asp:Button ID="saveButton" runat="server" OnClick="SaveButton_Click" Text="Speichern" CausesValidation="true"/> <asp:CustomValidator runat="server" ID="saveCValidator" Display="Static" OnServerValidate="EditPriceCValidator_ServerValidate" ControlToValidate="saveButton" ErrorMessage=""> When loading the page, I receive the error message: "Control 'saveButton' referenced by the ControlToValidate property of 'saveCValidator' cannot be validated." What might be the problem? I searched on the net, but this

Elegant way to make CustomValidator work with ValidationSummary messagebox

ぐ巨炮叔叔 提交于 2019-11-28 20:31:25
I have run into this problem before but never quite solved it. I have a form with several validators and also a CustomValidator. <asp:Label ID="lblMemberNum" runat="server" Text="Membership #:" CssClass="LabelMedium" ></asp:Label> <asp:TextBox ID="txtMemberNum" runat="server" CssClass="TextBox" ></asp:TextBox> <asp:RequiredFieldValidator ID="rfvMemberNum" SetFocusOnError="True" runat="server" ControlToValidate="txtMemberNum" ErrorMessage="[ Membership # ] is required" CssClass="ValidationMessage" Display="Dynamic" >*</asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="revMemberNum

ASP.NET Custom Validator Client side & Server Side validation not firing

风流意气都作罢 提交于 2019-11-28 16:28:26
This has not happened to me before, but for some reason both the client and server side validation events are not being triggered: <asp:TextBox ID="TextBoxDTownCity" runat="server" CssClass="contactfield" /> <asp:CustomValidator ID="CustomValidator2" runat="server" EnableClientScript="true" ErrorMessage="Delivery Town or City required" ClientValidationFunction="TextBoxDTownCityClient" ControlToValidate="TextBoxDTownCity" OnServerValidate="TextBoxDTownCity_Validate" Display="Dynamic" > </asp:CustomValidator> Server-side validation event: protected void TextBoxDTownCity_Validate(object source,

ASP.NET Custom Validator + WebMethod + jQuery

旧时模样 提交于 2019-11-28 11:24:18
I'm trying to implement a .NET Custom Validator that uses $.ajax to query a WebMethod on the same page and return a boolean value to indicate whether the result is true or false. The WebMethod I'm using is really simple [WebMethod()] public static bool IsPromoValid(string code) { string promoCode = "ABCDEFG"; bool result = code.ToLower() == promoCode.ToLower(); return result; } The CustomValidator looks like this <asp:CustomValidator ID="cvPromoCode" Display="None" ControlToValidate="txtPromoCode" runat="server" ClientValidationFunction="validatePromo" ErrorMessage="The promo code you entered

How to get the 'controlToValidate' property on ClientValidationFunction?

拈花ヽ惹草 提交于 2019-11-28 09:47:07
Lets say I have this code. <asp:TextBox ID="TextBox1" runat="server" /> <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ValidationFunction1" ControlToValidate="TextBox1" Display="Dynamic" /> And a validationFunction: function ValidationFunction1(sender, args) { } And i would like to know if, inside the function I could get the Control to validate something like: var v = sender.ControlToValidate; Musa Hafalır Actually sender.controltovalidate gives the ClientID of the control. So this seems like a solution. function ValidationFunction1(sender, args){ var v =

ASP.NET Custom Validator Error Message: Control referenced by the property cannot be validated

旧巷老猫 提交于 2019-11-28 02:38:40
问题 I use ASP.NET and have a Button and a CustomValidator, which has to validate the button. <asp:Button ID="saveButton" runat="server" OnClick="SaveButton_Click" Text="Speichern" CausesValidation="true"/> <asp:CustomValidator runat="server" ID="saveCValidator" Display="Static" OnServerValidate="EditPriceCValidator_ServerValidate" ControlToValidate="saveButton" ErrorMessage=""> When loading the page, I receive the error message: "Control 'saveButton' referenced by the ControlToValidate property

Where should Rails 3 custom validators be stored?

狂风中的少年 提交于 2019-11-27 18:14:08
I've seen docs/websites show that custom validators should go in a /lib or /lib/validators directory of a project. I've found (by reading an answer to another post) that they only seem to work in config/initializers . Does anyone know, or have a pointer to official documentation that shows where custom validators should live? If you place your custom validators in app/validators they will be automatically loaded without needing to alter your config/application.rb file. gunit888 If you add this to your /config/application.rb file: config.autoload_paths += %W["#{config.root}/lib/validators/"]

Elegant way to make CustomValidator work with ValidationSummary messagebox

北战南征 提交于 2019-11-27 12:57:58
问题 I have run into this problem before but never quite solved it. I have a form with several validators and also a CustomValidator. <asp:Label ID="lblMemberNum" runat="server" Text="Membership #:" CssClass="LabelMedium" ></asp:Label> <asp:TextBox ID="txtMemberNum" runat="server" CssClass="TextBox" ></asp:TextBox> <asp:RequiredFieldValidator ID="rfvMemberNum" SetFocusOnError="True" runat="server" ControlToValidate="txtMemberNum" ErrorMessage="[ Membership # ] is required" CssClass=