validation

Validating and ActiveRecord model based on an associated Model's data?

Hi everyone. SCENARIO: Given that a model called Edition has its community feature enabled I want all Records under that Edition to validate for the community field When the community feature is disabled, the community field will NOT be validated Basically, I am trying to write a custom validation function at the ActiveRecord level...

Custom DataAnnotations Validator Derived from RegularExpressionAttribute

The Gu provides an example of how you might create a custom validator that overrides RegularExpressionAttribute (http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx). The advantage of this is that you don't have to create a custom Model Validator (http://haacked.com/archive/2009/11/19/aspnetmvc2-custom-...

MySQL: How to check if a string is a valid DATE, TIME or DATETIME

When I try to put a value into a DATE field which is invalid, MySQL seems to use 0000-00-00 instead. Is there a way I can do this "check" without updating a DATE field? And to do it from for example PHP? Like, is there a way I can query the MySQL server and ask "Hey, is this DATE, TIME or DATETIME valid to you?" Or is there maybe an ev...

testing SpringMVC controllers

Hi, I'm unit-testing my SpringMVC (v. 2.5) controllers using code like the following: public void testParamValidation() { MyController controller = new MyController(); MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("foo", "bar"); request.addParameter("bar", baz"); ModelAndView ma...

How to validate keys on the virtual keyboard on Android?

I want to have a toast message to display "Enter numeric characters only" whenever the user presses a non-numeric key on the virtual keyboard. Any clue? ...

How can I create a generic UniqueValidationAttribute in C# and DataAnnotation?

I'm trying to create a UniqueAttribute using the System.ComponentModel.DataAnnotations.ValidationAttribute I want this to be generic as in I could pass the Linq DataContext, the table name, the field and validate if the incoming value is unique or not. Here is a non-compilable code fragment that I'm stuck at right now: using System; u...

Clicking on a asp.net button, how to scroll down the page when there is an error on the form.

My page scrolls down a bit, so the problem is when the ASP.NET validation kicks in (its a server side validation that sets a table row to visible if there was a failed validation for a given input box). The problem is, when there is an error, the page scrolls back to the top. How can I force the page to the bottom? I can use <a name="...

wcf generated classes and validation application block attributes

Hi, I'm new to the validation application block and trying to use it with wcf... I have a wcf service that has data objects with validation rules defined with attributes, using the validation application block . On my client side (WPF), I have a service reference. When I update the service reference the generated classes do not have th...

Best way to validate currency input?

I have created the TextBox and CompareValidator below which I thought would allow input in the following forms: 5 5.00 $5.00 Unfortunately it's not allowing the version with the dollar sign in it. What is the point of doing a type check against currency if you don't allow the dollar sign? Is there a way to allow this symbol? ...

Validate two properties against each other in ASP.NET MVC2, with DataAnnotations

For example, I'd like to validate a user registration form and check whether user has entered his password in "password" and "confirm password" fields, AND that those two values are the same. Found this but is reflection really the only way? ...

How can I use Ruby to check if a domain exists?

Something along the lines of: def domain_exists?(domain) # perform check # return true|false end puts "valid!" if domain_exists?("example.com") ...

WPF Validation with ContentPresenter

Hi, I have a WPF user control which needs to validate some fields. It is bound to a class implementing IDataErrorInfo. When I set the user control as the content of my ContentPresenter in another, already open, window, I can see validation occurring, and error messages being returned, however, I don't get any validation adorner - e.g....

Is there a PHP library that performs MySQL Data Validation and Sanitization According to Column Type?

Do you know of any open source library or framework that can perform some basic validation and escaping functionality for a MySQL Db. i envisage something along the lines of: //give it something to perform the quote() quoteInto() methods $lib->setSanitizor($MyZend_DBAdaptor); //tell it structure of the table - colnames/coltypes/ etc ...

How to validate unicode characters ?

Hello, I have one registration form, I don't want people to register login username with unicode characters. How can i put server side validation PHP + client side validation javascript or jquery. Please kindly help me out. Thank you. ...

ASP.NET MVC2 - Does Html.EnableClientValidation() work on the nested data model?

I have seen the client side validation examples and videos on internet by using Html.EnableClientValidation(). But all target on the simple data model. Does the Html.EnableClientValidation() work on the nested data model like below? public class Person { public Name Name { get; set; } public string Gender { get; set; } } ...

Struts Form Validation Don't Perform Validation Depending on button clicked

Hi. I have a j2ee web application running on struts. I am using validation XMLs for my form validation. I have a problem with multiple buttons in One form. I have Save, Delete and Cancel buttons. The problem is I want that when the delete button is clicked the validation is not performed. How do I do this. ...

jQuery Validation errorPlacement

This works: $("[id$='_zzz']").rules( "add", { required: true, minlength: 8, messages: { required: "...", minlength: jQuery.format("...") } } ); The error message comes up. When I try to style the message, this doesn't work: $("[id$='_zzz']").rules( "...

Struts2 : possible to use dynamic method invocation and specify different validation rules for different methods ?

I have in struts.xml : <action name="MyAction!*" class="my.Action" method="{1}"> <result name="step1">step1.jsp</result> <result name="step2">step2.jsp</result> <result name="error">error.jsp</result> </action> Then my my.Action class has various methods that can be called by specifying the nam...

jquery form validation: validation script specified externally

i have a jquery form validation in the master page and it works fine and i got that working from this article: http://www.dotnetcurry.com/ShowArticle.aspx?ID=310 my question is: if i place the .js to external and add a reference to my page then its not working... it says object expected here is how i have done: in my content page (i a...

Could someone critique my PHP register/validation classes?

http://pastie.org/931617 is a link to the source code. If there is a better way to do this, let me know. One thing I'm unsure about, is the way I handle child/parent constructs in the validation classes towards the bottom. Thanks. Ok, I took your advice using an associative array. Now, I just toss the $_POST variable to my construct...