var monthYear=0;
monthYear = $('#mYear').val();;
alert(mYear);
$("#pdate").datepicker
({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#pdate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
var filterDate = function(date) {
if(monthYear=='0'){
return [true];
}else{
return [(1+date.getMonth()) == monthYear];
}
}
$(document).ready(function() {
$("#sdata").click(function(evt) {
evt.preventDefault();
if(save()){
$.ajax({
url: "Test.jsp",
type: "post",
data: {
pS:$('#pS').val(),
pType:$('#pT').val(),
pCode:$('#pC').val(),
mYear:$('#mYear').val(),
pDate:$('#pdate').val(),
ppDate:$('#ppdate').val(),
bDate:$('#bdate').val()},
success: function(responseFromServer) {
$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {
$('#content').html(resultMessageKey);
});
getClearDateValues();
},
error: function() {
alert(" Ajax call Failed to Update Values into Database");
}
});
}
else
{
}
});
});
$(document).ready(function() {
$("#sdata").click(function(evt) {
evt.preventDefault();
if(save()){
$.ajax({
url: "Test.jsp",
type: "post",
data: {
pS:$('#pS').val(),
pType:$('#pT').val(),
pCode:$('#pC').val(),
mYear:$('#mYear').val(),
pDate:$('#pdate').val(),
ppDate:$('#ppdate').val(),
bDate:$('#bdate').val()
},
success: function(responseFromServer) {
$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {
$('#content').html(resultMessageKey);
});
getClearDateValues();
},
error: function() {
alert(" Ajax call Failed to Update Values into Database");
}
});
}
else
{
}
});
var monthYear=0;
monthYear = $('#mYear').val();;
alert(mYear);
$("#pdate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#pdate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#bdate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#bdate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#ppdate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#ppdate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
var filterDate = function(date) {
if(mYear=='0'){
return [true];
}else{
return [(1+date.getMonth()) == mYear];
}
}
});
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#sdata").click(function(evt) {
evt.preventDefault();
if(save()){
$.ajax({
url: "Test.jsp",
type: "post",
data: {
pS:$('#pS').val(),
pType:$('#pT').val(),
pCode:$('#pC').val(),
mYear:$('#mYear').val(),
pDate:$('#pdate').val(),
ppDate:$('#ppdate').val(),
bDate:$('#bdate').val()
},
success: function(responseFromServer) {
$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {
$('#content').html(resultMessageKey);
});
getClearDateValues();
},
error: function() {
alert(" Ajax call Failed to Update Values into Database");
}
});
}
else
{
}
});
var monthYear=0;
//monthYear = $('#mYear').val();
$("#pDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#pDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#ppDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#ppDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#bDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#bDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
var filterDate = function(date) {
monthYear = 2 ; //// here i hard coded month value
alert(monthYear);
if(monthYear=='0'){
return [true];
}else{
return [(1+date.getMonth()) == monthYear];
}
}
});
</script>
</head>
<body>
<form action="" id="myForm" method="post">
<select id="drop1">
<option value="0">Select Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
</select>
<input type="text" name="pDate" class="input-text datepickerwidth required" id="pDate" placeholder="Start Date*"/>
<input type="text" name="ppDate" class="input-text datepickerwidth required" id="ppDate" placeholder="Start Date*"/>
<input type="text" name="bDate" class="input-text datepickerwidth required" id="bDate" placeholder="Start Date*"/>
<input id="sdata" type="submit" value="submit" />
</form>
</body>
</html>
if(save()){
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#sdata").click(function(evt) {
evt.preventDefault();
if(save()){
$.ajax({
url: "Test.jsp",
type: "post",
data: {
pS:$('#pS').val(),
pType:$('#pT').val(),
pCode:$('#pC').val(),
mYear:$('#mYear').val(),
pDate:$('#pdate').val(),
ppDate:$('#ppdate').val(),
bDate:$('#bdate').val()
},
success: function(responseFromServer) {
$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {
$('#content').html(resultMessageKey);
});
getClearDateValues();
},
error: function() {
alert(" Ajax call Failed to Update Values into Database");
}
});
}
else
{
}
});
var monthYear=0;
//monthYear = $('#mYear').val();
$("#pDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#pDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#ppDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#ppDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#bDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#bDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
var filterDate = function(date) {
monthYear = 2 ; //// here i hard coded month value
alert(monthYear);
if(monthYear=='0'){
return [true];
}else{
return [(1+date.getMonth()) == monthYear];
}
}
});
function getClearDateValues(){
$("#pdate").val("");
$("#ppdate").val("");
$("#bdate").val("");
}
function save()
{
if(!ValidateJScrip())
return false;
var pdate,ppdate,bdate;
pdate = document.getElementById("pdate").value;
bdate = document.getElementById("ppdate").value;
ppdate = document.getElementById("bdate").value;
pdate1 = Date.parse(pdate);
bdate1 = Date.parse(bdate);
ppdate1 = Date.parse(ppdate);
if(document.forms.form2.pdate.value == '')
{
alert("Please select pDate");
document.forms.form2.pdate.focus();
return;
return true;
}
</script>
</head>
<body>
<form action="" id="myForm" method="post">
<select id="drop1">
<option value="0">Select Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
</select>
<input type="text" name="pDate" class="input-text datepickerwidth required" id="pDate" placeholder="Start Date*"/>
<input type="text" name="ppDate" class="input-text datepickerwidth required" id="ppDate" placeholder="Start Date*"/>
<input type="text" name="bDate" class="input-text datepickerwidth required" id="bDate" placeholder="Start Date*"/>
<input id="sdata" type="submit" value="submit" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#sdata").click(function(evt) {
evt.preventDefault();
if(true()){
$.ajax({
url: "Test.jsp",
type: "post",
data: {
pS:$('#pS').val(),
pType:$('#pT').val(),
pCode:$('#pC').val(),
mYear:$('#mYear').val(),
pDate:$('#pdate').val(),
ppDate:$('#ppdate').val(),
bDate:$('#bdate').val()
},
success: function(responseFromServer) {
$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {
$('#content').html(resultMessageKey);
});
getClearDateValues();
},
error: function() {
alert(" Ajax call Failed to Update Values into Database");
}
});
}
else
{
}
});
var monthYear=0;
//monthYear = $('#mYear').val();
$("#pDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#pDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#ppDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#ppDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#bDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#bDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
var filterDate = function(date) {
monthYear = 2 ; //// here i hard coded month value
alert(monthYear);
if(monthYear=='0'){
return [true];
}else{
return [(1+date.getMonth()) == monthYear];
}
}
});
function getClearDateValues(){
$("#pdate").val("");
$("#ppdate").val("");
$("#bdate").val("");
}
function save()
{
if(!ValidateJScrip())
return false;
var pdate,ppdate,bdate;
pdate = document.getElementById("pdate").value;
bdate = document.getElementById("ppdate").value;
ppdate = document.getElementById("bdate").value;
pdate1 = Date.parse(pdate);
bdate1 = Date.parse(bdate);
ppdate1 = Date.parse(ppdate);
if(document.forms.form2.pdate.value == '')
{
alert("Please select pDate");
document.forms.form2.pdate.focus();
return;
return true;
}
}
</script>
</head>
<body>
<form action="" id="myForm" method="post">
<select id="drop1">
<option value="0">Select Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
</select>
<input type="text" name="pDate" class="input-text datepickerwidth required" id="pDate" placeholder="Start Date*"/>
<input type="text" name="ppDate" class="input-text datepickerwidth required" id="ppDate" placeholder="Start Date*"/>
<input type="text" name="bDate" class="input-text datepickerwidth required" id="bDate" placeholder="Start Date*"/>
<input id="sdata" type="submit" value="submit" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#sdata").click(function(evt) {
evt.preventDefault();
if(true()){
$.ajax({
url: "Test.jsp",
type: "post",
data: {
pS:$('#pS').val(),
pType:$('#pT').val(),
pCode:$('#pC').val(),
mYear:$('#mYear').val(),
pDate:$('#pdate').val(),
ppDate:$('#ppdate').val(),
bDate:$('#bdate').val()
},
success: function(responseFromServer) {
$.each(responseFromServer, function(resultMessageKey,resultMessageValue) {
$('#content').html(resultMessageKey);
});
getClearDateValues();
},
error: function() {
alert(" Ajax call Failed to Update Values into Database");
}
});
}
else
{
}
});
var monthYear=0;
//monthYear = $('#mYear').val();
$("#pDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#pDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#ppDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#ppDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
$("#bDate").datepicker({
minDate:"dateToday",
dateFormat: 'dd/mm/yy',
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#bDate").datepicker("option", "minDate", selectedDate);
},
//Code to disable dates according to selection
beforeShowDay: filterDate
});
});
var filterDate = function(date) {
monthYear = 2 ; //// here i hard coded month value
alert(monthYear);
if(monthYear=='0'){
return [true];
}else{
return [(1+date.getMonth()) == monthYear];
}
}
function getClearDateValues(){
$("#pdate").val("");
$("#ppdate").val("");
$("#bdate").val("");
}
function save()
{
if(!ValidateJScrip())
return false;
var pdate,ppdate,bdate;
pdate = document.getElementById("pdate").value;
bdate = document.getElementById("ppdate").value;
ppdate = document.getElementById("bdate").value;
pdate1 = Date.parse(pdate);
bdate1 = Date.parse(bdate);
ppdate1 = Date.parse(ppdate);
if(document.forms.form2.pdate.value == '')
{
alert("Please select pDate");
document.forms.form2.pdate.focus();
return;
return true;
}
}
</script>
</head>
<body>
<form action="" id="myForm" method="post">
<select id="drop1">
<option value="0">Select Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
</select>
<input type="text" name="pDate" class="input-text datepickerwidth required" id="pDate" placeholder="Start Date*"/>
<input type="text" name="ppDate" class="input-text datepickerwidth required" id="ppDate" placeholder="Start Date*"/>
<input type="text" name="bDate" class="input-text datepickerwidth required" id="bDate" placeholder="Start Date*"/>
<input id="sdata" type="submit" value="submit" />
</form>
</body>
</html>
monthYear = $("#drop1").val();
Open in new window