form-validation

jQuery Form Validation Plugin: Requiring e-mails to be .EDU addresses

I'm trying to build a sign-up form that will only accept .EDU e-mail addresses. I also want to keep the AJAX functionality I have (using the "remote" parameter) to ensure that the e-mail address hasn't been used before. How can I do this? ...

Validating a Unicode Name

In ASCII, validating a name isn't too difficult: just make sure all the characters are alphabetical. But what about in Unicode (utf-8) ? How can I make sure there are no commas or underscores (outside of ASCII scope) in a given string? (ideally in Python) ...

How can I mark a form/field as "dirty" if it's databound?

If I have a databound form, how do I know if a user has modified it (either by typing text into a text box, or by selecting an item in a combobox)? I've tried hooking into my textbox's "TextChanged" event, but the problem is that, when my form participates in databinding, the "TextChanged" event fires, prematurely marking my form as "dir...

IDataErrorInfo : Not validating input

I have a user control which contains a textbox. I have a class called Person which implements IDataErrorInfo interface: class Person : IDataErrorInfo { private bool hasErrors = false; #region IDataErrorInfo Members public string Error { get { string error = null; ...

ASP.net MVC How to change the Textbox Class upon validation failure?

I notice in the default MVC template project that the Account registration fields are highlighted via a class change. I can't seem to get the same behavour out of my own code (in the same project - same CSS etc) What might be stopping this from occuring? Update I believe this relates to one of my other questions Because I was having...

PHP form class

I'm used to ASPNET and Django's methods of doing forms: nice object-orientated handlers, where you can specify regexes for validation and do everything in a very simple way. After months living happily without it, I've had to come back to PHP for a project and noticed that everything I used to do with PHP forms (manual output, manual va...

Validating Form Fields in an ITemplate

I have a custom control which includes a property of the following definition: [PersistenceMode(PersistenceMode.InnerProperty)] public ITemplate Template { get { return template; } set { template = value; } } The control overrides CreateChildControls(), and adds several HtmlGenericControls and an asp:Panel control. The actual ac...

what is the built-in javascript function to return the validator state in asp.net

This is a bit of a tough question to ask. I am using asp.net validators, but I want to tie them to a simple click event which I bind with jQuery. I have found that I can use: ValidatorValidate($("#<%= rfvFirst.ClientID %>")[0]); to fire the rfvFirst validator, but I do not know how to get the actual false return somewhere to tell me...

ASP.NET MVC - Custom validation message for value types

When I use UpdateModel or TryUpdateModel, the MVC framework is smart enough to know if you are trying to pass in a null into a value type (e.g. the user forgets to fill out the required Birth Day field) . Unfortunately, I don't know how to override the default message, "A value is required." in the summary into something more meaningful...

Simplest JQuery validation rules example

The following HTML form successfully utilizes jQuery's form validation, displaying "This field is required" to the right of the form field if left blank, and "Please enter at least 2 characters" if fewer than 2 characters were entered. However, instead of the validation metadata being specified using the class and minlength attributes o...

ASP.NET MVC RC2 - Why can't I use the normal validation options? e.g. RequiredFieldValidator

I'm trying to validate a basic form, can i not use the standard validation controls? Everywhere i'm looking seems to try and use something like the below <%= Html.ValidationSummary() %> <% using (Html.BeginForm()) {%> <fieldset class="fields"> <legend>Create New Contact</legend> <p> <label for="task">Ta...

ASP.net RequiredFieldValidator not preventing postback

I have a question about what could stop a RequiredFieldValidator from preventing a postback. I began working on an older, but simple aspx form and my predecessor used manual, server-side form validation (checking to see if some form fields have a value and if not displaying an error message in a label). I thought I'd clean out some unn...

Should validation be done in Form objects, or the model?

This question is mainly geared towards Zend in PHP, although it certainly applies to other languages and frameworks, so I welcome everyone's opinion. I've only recently been using the Zend framework, and while it's not perfect, I have had a pretty good time with it. One thing that drives me crazy, however, is that most of the examples ...

javascript regexp, validating date problem

Hi there, I have some code for validating date below: function validateForm() { var errFound = 0; //var patt_date = new RegExp("^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))$"); var pat...

Hijacking Form Submission on ASP.NET MVC with jQuery (or other)

I'm using ASP.NET MVC (v1.0) on an app and want to integrate simple client-side form validation. IE: Numeric-Only fields, required fields, etc. Is there good, and potentially eye-candy fancy, method of validating in jQuery on the client that will cancel form submission on failed validation? I've perused and experimented with quite a fe...

How to validate an outside form field in a Ruby on Rails form (such as a captcha)?

I have a user registration form, and wanted to write a human detecting "captcha" into my register method. I decided to create a simple math question for users to answer (this should work for my purposes). How do I write a validation that checks the value of this field? I wrote a validate method in my model file as follows: def validat...

What are best practices for validating ASP.Net user controls?

I'm wondering if any best practices exist for guidelines as to what should and should not go into a validator control. My thought and practice was that it should be basic sanity checking (i.e. did the user enter all the required inputs? Is there 10 digits in the phone number, is the email address in the valid form? etc..), but I've recen...

Display message after form validation & before result page

I have a form that uses the excellent jQuery validation plugin. This is a multi-stage form, one of which involves uploading files, which are scanned for viruses before being accepted. As the upload & virus scan can take a while, I would ideally like to show the user an interim message, preferably in a modal-overlay style, which stays ar...

trying to submit rich text editor content in asp.net mvc and getting "potentially dangerous Request.Form value was detected"

I am using TinyMCE in asp.net mvc and getting the error message "a potentially dangerous Request.Form value was detected" when trying to save the text from the TinyMCE editor. I set ValidateRequest="false" both in web.config and on the page. Any ideas? ...

ZF: Login Form Validation

WHat's the best way/code in Login Form (Zend_Form) to display error message 'Login/password incorrect'? I slowly begin to understand, that setting $this->setErrorMessage('Login/password incorrect') in form/init() is not enough and I somehow have to involve Validators to be able to see the message I set. To which object should I bind th...