I have a jquery date picker that pops up everytime I click my textbox(prfm_dtrequest). It returns mm/dd/yyyy format which is the way I want it to be. I need to validate the content of the textbox afterwards to make sure it is in the correct format before loading it into my database when clicking the submit button(#submitform). My code below only returns "is not a valid date" even if I
<!DOCTYPE html>
<html lang="en">
<head>
<title>testing</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#prfm_dtrequest" ).datepicker();
});
</script>
<script>
$(document).ready(function(){
$("#submitform").click(function(){
var daterequested = $("#prfm_dtrequest").val();
var dateMMDDYYYRegex = /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/ ;
if(dateMMDDYYYRegex.test(dateMMDDYYYRegex)){
alert('is a valid date: '+daterequested);
}else{
alert('is not a valid date: '+daterequested);
}
});
});
</script>
</head>
<meta charset="utf-8">
<body>
<form method='post' action=''>
<input type="date" id="prfm_dtrequest" class='txtfld01' name=''><input type="submit" id="submitform" value="submit">
</form>
</body>
</html>