Jump to content

Date multiple field validation


swati

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...