views:

146

answers:

1

Hi,

I'm using ui.datepicker.js and I want to validate the date field to make sure the user select a date.

I have tried

function allow_submit()
{

 var f = document.all.frm;

  if (f.date.value == "") {
    jAlert("Please select a date");
    return false;
  } //if

  return true;
}

and also have try

if (f.date.value == "0000-00-00") {

without succes

Any clue?

+1  A: 

Since you already have jQuery referenced on the page, why not leverage that power?

Assuming you've followed their convention and assigned a class of "datepicker" to your input element, try this:

function allow_submit() {
  if($(".datepicker").val() == "") return false;
  return true;
}
BradBrening
Hi have tested but no succes here is my input code <input type=text name=date size=10 id="dp" value="<?php echo $date; ?> ">
lena
Try replacing ".datepicker" with "#dp" and see if that helps.
BradBrening
Ok thanks this is working perfectly with "#dp"
lena