Jump to content

Recommended Posts

Posted

Hi,

I want to validate a date field in the format :

DD - single textbox

MM -single textbox

YYYY -single textbox

 

Three textbox fields are there, have to do the separate validation for date(DD),month(MM),year (YYYY)

 

var v_myProfileEditForm = $("#myProfileEditForm").validate({

rules: {

title: { required: true },

name: { required: true },

lname: { required: true },

dob:{date: true, dateOfBirth: true}

},

this dob rule wont work for me, can you help me out for these 3 fields separate validations ?

 

Thanks

Posted

I believe you are using this, correct? http://docs.jquery.com/Plugins/validation

 

To be honest, I wouldn't use text boxes for this. I would use three dropdown select boxs instead (or two selects for day/month and a text input for year?) Day would range from 1-31, month from 1-12, etc. Then you just need to make sure that a value for each field has been selected.

 

If you do text boxes, seems like you would want to use digits() to confirm you are only dealing with numbers, and you could use range() (http://docs.jquery.com/Plugins/Validation/Methods/range#range) to specify the range of numbers that are available.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...