validation

Where and how to do custom validation on models?

Lets say we have a simple model that stores two integers, the min and the max. We would like to force min <= max. class MinMax include MongoMapper::Document key :min, Integer key :max, Integer validate_presence_of :min, :max end 1) How would you validate that min is indeed equal or less than max? 2) If you don't think this ...

How to validate for different clients with DataAnnotations in .NET

If you write your validation requirements into the domain object using DataAnnotations how can you vary these depending on the UI that accesses it - for example the validation requirements of a user signup form may be different from the requirements of the administrators form - yet they both use the same domain object behind the scenes. ...

ASP.NET MVC2 -- Trouble with Model Binding and Html.Textbox()

ASP.NET MVC Model Binding is still new to me and I'm trying to understand exactly how it works. Right now, I appear to be having problems with a feature of Html.Textbox() Specifically, I have a View where I set Html.Textbox to a value both in the "Get" and the "Post". It sets fine in the "Get", but after the user submits a value during ...

Programatically disabling jQuery client validation in ASP.NET MVC

I am using the jQuery MVC validation library for ASP.NET MVC, which is working fine. However, on my form I have a 'Cancel' and a 'Save' button, both of which I want to submit the form back to the server. However, if the user clicks 'Cancel' I need to disable the client side validation so that the user doesn't get prompted to complete...

How can I validate optional HTML closing tags and missing /'s?

Are there any freely available tools that would check for things like a missing </p> or <br> (instead of <br />)? Thanks! ...

MVC 2 Client and Server Validation with Data Annotations - Required not working

I have a Create view which is passed a ViewModel. The ViewModel contains the following: namespace MyProject.ViewModels { public class MyObjectCreateView { public MyObject MyObject { get; set; } public List<OtherObject> OtherObjects { get; set; } } } The objects are generated using Entity Framework. I have...

Webform validation Drupal

I'm looking to add some speacial validation with webform through Drupal. It seems the old forms you could add extra PHP code to "Advanced Settings". According to this link we shouldn't be doing this anymore. (Running Drupal 6) What I have is a check box that makes a few fields disappear and a few different fields appears. So for my vali...

jsf validation issue - applies required field validation for disabled input fields

Hello, I am having problem with required=true validation which is applied on disabled fields. I have an a4j:commandButton and two dropdowns containing list of states and list of countries inside a form. Both the dropdowns have required="true" validation applied. state dropdown is enabled and country dropdown is disabled by default by u...

Doing all validation at once

When trying to validate controls on a windows form I realise the .validated() for each controls fires when the focus is lost. Instead I'd like to validate only when the button is pressed at the bottom, how would I do this? ...

Rails - field_error_proc and custom form fields.

In rails forms built with form_for, all of the fields called on the form object f are wrapped in an error div if they have caused a validation failure and the form page is re-rendered. However, if i have a form that has hand-built fields, instead of fields called on the form object f, they don't get this. Is there a way that i can trig...

JSON Framework and user input validation

Hi guys, I use JSON framework in my iPhone application to send text user input to server. This data will be stored in DB and displayed on web afterwards. I want to ask what I should be aware of safety-wise. I tried to add to my input different symbols (like ":" , "} and so on) to close/break my JSON but it seems that JSON Framework ...

Why does my button not show up?

Hello, I have a partial view where I render, if the user has choosen an option, a button that permit the user to generate automatically a value for a certain field. Please give a look at this picture to understand what I mean: This is achieved using the following markup on the partial view <%= Html.LabelFor( model => model.IssueCode...

all values same sign validation.

User should insert all the values either positive or negative. How may i set same sign validation ? Right i have written this on before_save .. unless (self.alt_1 >= 0 && self.alt_2 >=0 && self.alt_3 >= 0 && self.alt_4 >= 0 && self.alt_5 >= 0 && self.alt_6 >= 0) || (self.alt_1 <= 0 && self.alt_2 <=0 && self.alt_3 <= 0 && ...

Silverlight (like) Validation in Windows Form app

I need to Enable/Disable my SAVE button in real time based on data in my fields. Is the below an acceptable way on accomplishing this? It feels wrong but I don't know how else I could accomplish this. Each User Control(CRUD Form) has a BackgroundWorker and the following related methods; StartBGWorker() StopBGWorker() RequiredFields...

jQuery UI Autocomplete Validation

Hi, I am trying to perform some sort of text field validation before the Autocomplete request results for the inputted text. My code: <script type="text/javascript" src="/scripts/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/scripts/jquery-ui-1.8.2.min.js"></script> <script type="text/javascript"> $(function() {...

php url parameters check

Hi, I'm creating a website that relays on $_GET to function correctly. It works like this: http://www.example.com/show?q=14&amp;i=48 q and i are IDs on MySQL server that must be fetched using mysql_query() and the like. Parameters are always integers. If someones type the url without any parameters both PHP and MySQL yells errors. PHP...

Validating a radio button is checked with jQuery

On my form I havea set of radio buttons. Here's the mark up: <div class="optionHolder"> <p class="optionName">Format</p> <div class="option checked"> <input type="radio" name="fileType" value="avi" /> <img src="images/avi.png" alt="" /> <label>AVI</label> </div> <div class="option"> <input...

MVC ClientSide date validation

I'm using xVal and jQuery for clientside form validation in MVC. A date field annotated with [DataType(DataType.Date, ErrorMessage=...)] is being properly validated if the user types a string that does not fit into the designated format. But if the user types something with invalid month or day, e.g., 13/32/2010, it is not validate unti...

ASP.NET MVC [HttpPost] action accepts single object, spits back validation errors to ViewPage<CustomViewModel>

I'm experimenting with different combinations of strongly typed view models, full views and partial views, using both RenderPartial() and RenderAction(). The form-post scenario I'm asking about, though, is one that comes from the "main" view--one that isn't a partial. This main view's controller constructs the view model that provides ...

How can I use the Data Validation Attributes in C# in a non-ASP.net context?

I'd like to use the data validation attributes in a library assembly, so that any consumer of the data can validate it without using a ModelBinder (in a console application, for instance). How can I do it? ...