0

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 Answer 1

2

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;
}
Sign up to request clarification or add additional context in comments.

2 Comments

Hi have tested but no succes here is my input code <input type=text name=date size=10 id="dp" value="<?php echo $date; ?> ">
Try replacing ".datepicker" with "#dp" and see if that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.