validation

Restricting empty elements in xsd

Is there a way to prevent empty elements of the form <myElement/> being used in your xml? In other words, can you specify in your xsd that <myElement/> is invalid? Using nillable="false" doesn't work, nor does minOccurs="1" - both of those allow <myElement/>. ...

Validating ModelChoiceField in Django forms

I'm trying to validate a form containing a ModelChoiceField: forms.py: from django import forms from modelchoicetest.models import SomeObject class SomeObjectAddForm(forms.ModelForm): class Meta: model = SomeObject models.py: from django.db import models class SomeChoice(models.Model): name = models.CharField(max_...

jQuery Validation Plugin: Invoke errorPlacement function when onfocusout, keyup and click

Hi, I am using the jquery validation plugin and want to use the errorPlacement function to add error messages to the fields title attribute and display just a ✘ next to the field. This works great when the form is submitted with the submit button but when any of the following events are triggered: - onfocusout - click - onkeyup The ...

Validation in asp.net MVC - validation only to happen when "asked"

I've got a slightly different validation requirement than the usual "when save, validate!". The system can allow someone to update a bunch of times without being "bothered" with a validation listing UNTIL they say it's complete. I thought I might be able to pull a fast one and put the [HandleError] on the method of which this would fir...

How can I know if an SQLexception was thrown because of foreign key violation?

I want to tell the user that a record was not deleted because it has child data, but how can I be sure that the exception was thrown because of a foreign key violation? I see that there a sqlexception class that is used for all sql exception. ...

iphone - Regex for date in user entered textfield

Hi all, Am a newbie to iphone programming. i have a input box and the user can write his DOB(mm/dd/yyyy) into the box. Before i save the data i like to test for valid input. I am using Regexlite.h and Regexlite.m.i have the regular expression too. i want to compare the regex to the user entered value in text box.But am not knowing how ...

jQuery validate before ajaxForm

I am trying to use the "beforeSubmit" option in the jQuery ajaxForm plugin to validate the data, however the form will submit even if there are invalid form fields. Where have I gone wrong? thanks, $(document).ready(function() { function validator(){ $("#commentForm").validate(); } $('#commentForm').ajaxForm({ da...

How to validate an expression in JavaScript?

I have an expression in {YYYY}-{MM} format, and I have a textbox in which I will take input from user. The user must input in above format for example: {2010}-{03} or {10}-{3} or {2010}-{3} How do I validate this using JavaScript? Thank You ...

How can I validate the output of XmlSerializer?

In C# / .NET 2.0, when I serialize an object using XmlSerializer, what's the easiest way to validate the output against an XML schema? The problem is that it is all too easy to write invalid XML with the XmlSerializer, and I can't find a way to validate the XML that does not look cumbersome. Ideally I would expect to set the schema in ...

Jquery DateJs, is there validation for full date?

Hi all, I just find out about the power of date js, And its great!!! As I am a newbie I was wondering if there is any kind of general validitation for different types of full dates. eg. var d1 = Date.parse('2000-10-18, 10:06 AM'); alert(d1.toString('HH:mm')); If date is ('200-10-18, 10:06 AM'), of course it doesn't like it. So my q...

Jquery checking that passwords match with php + Json

I have a form that I am validating with JS and PHP. Everything is going well so far apart from when I try to check if the passwords match. Here is the form: <div> <label for="passlength">Password, valid: 0-9</label> <input type="text" name="passlength" value="<?=@$_REQUEST['passlength']?>" id="p...

How do i validate classfields?

Is this a good aproach to making sure the fields has valid values for a database? internal class Customer { private string _CustomerId; internal string CustomerId { get { return (_CustomerId==null?string.Empty:(_CustomerId.Length>20?_CustomerId.Substring(0,20):_CustomerId)); } ...

Validation/binding in Symfony Ajax form submission?

Hi, I'm using Symfony 1.4. I'm posting a form via Jquery ajax to an action which seems to work fine except that it's unable to bind the form and access the variables in the normal symfony way: if ($request->isXmlHttpRequest()) { $this->form = new MessageForm(); if($request->isMethod('post')) { $this->form->bind($r...

Reg Ex - not allowing zero

Hi, Excuse my ignorance. My knowledge of regular expressions is extremely limited. I have the following regular expression on a regular expression validator. ^(\d{1,3},?(\d{3},?){0,2}\d{3}|\d{1,3})$ It currently allows zero. I need to update it so that it does not allow a value of 0. [Edit: Just to clarify, I would like it to excl...

jquery form validation > FIREFOX PROBLEM

This is a form validation that will hide the submit button if the input field(s) are not valid, and show it if all the input fields are valid. Why is the submit button kept invisible in firefox after all inputs have been made valid once again, when that doesn't happen in other browsers? This is the javascript in question: $(document)....

Rails: How can I loop through validation errors?

I'm building an API for my app and would like to return errors in the XML response that are generated by validation errors. So say you're registering on the site, right now the validation errors returned might be: Login has already been taken Password is too short (minimum is 6 characters) Email has already been taken But I'd like to...

Don't submit form unless JavaScript is enabled

I have a basic form that I'm using for member registration. I'm using the form onsubmit event to populate a hidden form field based on some of the form's fields. It's working great, but I'd like to prevent the form from submitting if javascript is NOT enabled. This will ensure that the hidden field gets properly populated on the clien...

jQuery.validator cannot assign default ignore selector to jQuery.validator.defaults.ignore

I know from here that I can pass an ignore option in the jQuery.validate method like this... $('form').validate({ ignore: ":hidden" }); ... which works fine, but I wanted to set the validator to ignore ":hidden" form fields by default... I've tried the following: jQuery.validator.defaults.ignore.push(":hidden"); ... but it does...

How reliable is the MaxLength property of the TextBox-Control?

The TextBox control offers a MaxLength property, which allows the insertable text into that TextBox be clientside limited to the specified amount of chars. My questions: Is this property only client-side and therefore browser-pedendent? Can I rely on the fact, that the Text property contains no text longer than MaxLength is set (only ...

Problems with validates_inclusion_of, acts_as_tree and rspec

I have problems to get rspec running properly to test validates_inclusion_of my migration looks like this: class CreateCategories < ActiveRecord::Migration def self.up create_table :categories do |t| t.string :name t.integer :parent_id t.timestamps end end def self.down drop_table :categories end e...