rendered paste body
<script language = "Javascript">
/**
* DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}
function isDate(dtStr){
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){
//alert("The date format should be : mm/dd/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
// alert("Please enter a valid month")
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
// alert("Please enter a valid day")
return false
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
// alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
// alert("Please enter a valid date")
return false
}
return true
}
function jqisdatevalid(divname){
var datecheckcontainer='#' + divname + 'datechecker'
var yearDiv='#' + divname + 'yyyy';
var monthDiv='#' + divname + 'mm';
var dayDiv='#' + divname + 'dd';
var dayDivVal=$(dayDiv).val();
var monthDivVal=$(monthDiv).val();
var yearDivVal=$(yearDiv).val();
if (!yearDivVal) { $(yearDiv).val("1900"); yearDivVal="1900" };
if (!monthDivVal) { $(yearDiv).val("01");monthDivVal="01"; };
if (!dayDivVal) { $(yearDiv).val("01"); monthDivVal="01"; };
var dateDivMerged=monthDivVal + "/" + dayDivVal + "/" + yearDivVal;
var finaldate=dateDivMerged;
if (isDate(finaldate)==false){
$(datecheckcontainer).attr("value","0");
} else {
$(datecheckcontainer).attr("value","1");
return 1;
}}
</script>
<!-- @@@@@@@@@@@@@@ Begin Form MyForm1 @@@@@@@@@@@@@@ -->
<form method="post" name='MyForm1' id='MyForm1' action="/remote/proccessajax.php">
<div>
<label class="label"> ubirthday </label>
<select name="ubirthday[dd]" tabindex=301 onchange="jqisdatevalid('ubirthday');" id='ubirthdaydd'><option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select><select name="ubirthday[mm]" onchange="jqisdatevalid('ubirthday');" tabindex=302 id='ubirthdaymm'><option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select><select name="ubirthday[yyyy]" onchange="jqisdatevalid(ubirthday);" tabindex=303 id='ubirthdayyyyy'><option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
<option value="1994">1994</option>
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
</select>
<input name='ubirthdaydatechecker' type='text' id='ubirthdaydatechecker' value='0' lengh="1" maxlength='1' style="display:none" />
</div>
<DIV class=buttonrow>
<input type="submit" id="submitMyForm1" name="Submit" value="Submit">
</div>
</fieldset>
</form>
</div>
</div>
</div>
<div id='MyForm1loaderdivbottom1'>
<center>
<img id='MyForm1loaderdivbottom1img' src=''>
</center>
</div>
<!-- @@@@@@@@@@@@@@ END Form MyForm1 @@@@@@@@@@@@@@ -->
<!-- @@@@@@@@@@@@@@ Begin AjaxCall MyForm1 @@@@@@@@@@@@@@ -->
<script type="text/javascript">
$.validator.addMethod("mustvailddate", function(value) {
return value == "1";
}, 'Invaild date!!!!!');
$("#MyForm1loaderdivbottom1img").attr("src","http://crazilla.linuxlab/images/icons/loading/loadingbar.gif");
$('#dhtmltooltiptext').css('color', 'black');
$(function() {
$().ajaxStart(function() {
$.blockUI( '<h1><img src="http://bl.linuxlab/images/icons/loading/loading1.gif" /><BR> Just a moment...</h1>' );
}).ajaxStop(function() {
$.unblockUI();
});
$().ajaxError(function(a, b, e) {
throw e;
});
$.validator.setDefaults({
debug: false
});
var v = $("#MyForm1").validate({
/////// begin rules //////////////////////////////////////////
rules: {
ubirthdaydatechecker: { mustvailddate: true
} },
/////////// end rules ///////////////////
focusInvalid: "false",
event: "keyup",
submitHandler: function(form) {
$(form).ajaxSubmit({
dataType: "json",
data: data,
beforeSubmit: function (fd) {
},
after: function(result) {
if (result.status == 0) { v.showErrors(result.data);
}
if (result.status == 2) { alert(result.data); }
if (result.status == 3) {
}
if( result.status == 1) {
alert('done'); }
}
});
}
});
$().ajaxComplete(function(e, xhr, s) {
// alert(xhr.responseText);
});
});
</script>