1 function isAlpha(field) 2 { 3 4 field1=trim(field) 5 6 var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 7 var ok = "yes"; 8 var temp; 9 // Iterates through the field length to check each character is alphanueric or not 10 for (var i=0; i<field.value.length; i++) 11 { 12 temp = "" + field.value.substring(i, i+1); 13 // If any character is not alphanumeric then assigns "no" to ok 14 if (valid.indexOf(temp) == "-1") ok = "no"; 15 } 16 // If ok is "yes" then returns true 17 if (ok == "yes") 18 { 19 return true 20 } 21 // Otherwise returns false 22 return false 23 } 24 // 25 function trim(inputString) 26 { 27 // Removes leading and trailing spaces from the passed string. Also 28 // removes consecutive spaces and replaces it with one space. 29 var retValue = inputString; 30 31 if(retValue!="") 32 { 33 retValue = String(retValue); 34 var ch = retValue.substring(0, 1); 35 while (ch == " ") 36 { 37 // Check for spaces at the beginning of the string 38 retValue = retValue.substring(1, retValue.length); 39 ch = retValue.substring(0, 1); 40 } 41 42 ch = retValue.substring(retValue.length-1, retValue.length); 43 while (ch == " ") 44 { 45 // Check for spaces at the end of the string 46 retValue = retValue.substring(0, retValue.length-1); 47 ch = retValue.substring(retValue.length-1, retValue.length); 48 } 49 50 while (retValue.indexOf(" ") != -1) 51 { 52 // Note that there are two spaces in the string - look for multiple spaces within the string 53 retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings 54 } 55 } 56 return retValue; 57 } // Ends the "trim" function 58 59 // Checks whether the given string is numeric or not 60 function isNumeric(field) 61 { 62 field1=trim(field) 63 64 var valid = "0123456789" 65 var ok = "yes"; 66 var temp; 67 // Iterates through the field to check each character is numeric or not 68 for (var i=0; i<field.value.length; i++) 69 { 70 temp = "" + field.value.substring(i, i+1); 71 // If any character is non-numeric assigns "no" to ok 72 if (valid.indexOf(temp) == "-1") ok = "no"; 73 } 74 75 // If ok equals "yes" returns true 76 // Otherwise returns false 77 if (ok == "yes") 78 { 79 return true 80 } 81 return false 82 } 83 84 85 86 // Checks whether the given string is numeric or not 87 function isValidPhone(field) 88 { 89 field1=trim(field) 90 91 var valid = "0123456789,-/;" 92 var ok = "yes"; 93 var temp; 94 // Iterates through the field to check each character is numeric or not 95 for (var i=0; i<field.value.length; i++) 96 { 97 temp = "" + field.value.substring(i, i+1); 98 // If any character is non-numeric assigns "no" to ok 99 if (valid.indexOf(temp) == "-1") ok = "no"; 100 } 101 102 // If ok equals "yes" returns true 103 // Otherwise returns false 104 if (ok == "yes") 105 { 106 return true 107 } 108 return false 109 } 110 111 function isValidDecimal(argvalue) 112 { 113 114 //var comma=','; 115 var period='.'; 116 117 var checkOK = "0123456789"+period ; 118 var checkStr = argvalue; 119 var allValid = true; 120 var decPoints = 0; 121 var allNum = ""; 122 //alert("length : "+ argvalue.value.length); 123 for (i = 0; i < argvalue.value.length; i++) 124 { 125 ch = checkStr.value.charAt(i); 126 for (j = 0; j < checkOK.length; j++) 127 if (ch == checkOK.charAt(j)) 128 break; 129 if (j == checkOK.length) 130 { 131 allValid = false; 132 break; 133 } 134 if (ch != ".") 135 allNum += ch; 136 } 137 if (!allValid) 138 { 139 140 return (false); 141 } 142 143 } 144 // Checks whether the given string is numeric or not 145function isDecimal(field) 146{ 147 field1=trim(field) 148 var count=0; 149 var valid = "0123456789." 150 var ok = "yes"; 151 var temp; 152 // Iterates through the field to check each character is numeric or not 153 for (var i=0; i<field.value.length; i++) 154 { 155 temp = "" + field.value.substring(i, i+1); 156 // If any character is non-numeric assigns "no" to ok 157 if (valid.indexOf(temp) == "-1") ok = "no"; 158 } 159 160 for (var i=0; i<field.value.length; i++) 161 { 162 163 if(field.value.charAt(i)== ".") count=count+1; 164 } 165 if(count >=2)ok = "no"; 166 // Otherwise returns false 167 if (ok == "yes") 168 { 169 return true 170 } 171 return false 172} 173 174 175 // Checks whether the given string is numeric or not 176 function isDecimalFor42(field, name) 177 { 178 179 field1=trim(field) 180 field1 = field.value; 181 field2 = trim(field) 182 var isValidField = "true";
183 var valid = "0123456789." 184 var ok = "yes"; 185 var temp; 186 // Iterates through the field to check each character is numeric or not 187 for (var i=0; i<field.value.length; i++) 188 { 189 temp = "" + field.value.substring(i, i+1); 190 // If any character is non-numeric assigns "no" to ok 191 if (valid.indexOf(temp) == "-1") ok = "no"; 192 193 } 194 195 // If ok equals "yes" returns true 196 // Otherwise returns false 197 if (ok == "yes") 198 { 199 var hr=field.value; 200 var st = new String(hr); 201 var i = st.indexOf("."); 202 if (i == field.value.length - 1) { 203 alert("Invalid "+name+" :Should be of 00.00 format"); 204 field.focus(); 205 return false; 206 } 207 if (i > 2) { 208 alert("Invalid "+name+" :Should be of 00.00 format"); 209 field.focus(); 210 return false; 211 } 212 var mm=st.substring(i+1,hr.length); 213 mm = trim(mm); 214 if(mm.length == 1){ 215 mm = "0" + mm; 216 } 217 var m=parseInt(mm); 218 var hh=''; 219 if (i==2){ 220 hh=st.substring(0,2); 221 } 222 hh = trim(hh); 223 if (i==1){ 224 hh=st.substring(0,1); 225 hh = "0" + hh; 226 } 227 228 var h=parseInt(hh); 229 230 field=hh+'.'+mm; 231 232 field1 = field; 233 if ((field1.indexOf(".") == (field1.length-1)) && (field1 != "")) { 234 alert("Invalid "+name+" :Should be of 00.00 format"); 235 isValidField = "false"; 236 field.focus(); 237 return false 238 } 239 if (field1.indexOf(".") == -1 && field.length > 2) { 240 alert("Invalid "+name+" :Should be of 00.00 format"); 241 isValidField = "false"; 242 field.focus(); 243 return false 244 } 245 if (field1.indexOf(".") == 0 && field.length > 3) { 246 alert("Invalid "+name+" :Should be of 00.00 format"); 247 isValidField = "false" ; 248// field.focus(); 249 return false 250 } 251 // Checks if session rate is a whole number and within the given range 252 if (field1.indexOf(".") == -1 && isValidField == "true") { 253 // If field is not empty then adds ".0" to field 254 if (field != "") { 255 field.value += ".00"; 256 } 257 // Otherwise sets the focus to field field 258 else { 259 field.focus(); 260 } 261 return true 262 } 263 264 if (field1.indexOf(".") == 0 && isValidField == "true") { 265 // If field is not empty then adds "0." to field 266 if (field != "") { 267 field.value = "00" + field.value; 268 } 269 // Otherwise sets the focus to session rate field 270 else { 271 field.focus(); 272 } 273 return true 274 275 } 276 if(field1 <= "99.99"){ 277 return true 278 } 279 }else{ 280 alert("Invalid "+name+" :Should be of 00.00 format"); 281 field.focus(); 282 return false 283 } 284 } 285 286 // Checks whether the given string is numeric or not 287 function isDecimalFor62(field, name) 288 { 289 290 field1=trim(field) 291 field1 = field.value; 292 field2 = trim(field) 293 var isValidField = "true"; 294 var valid = "0123456789." 295 var ok = "yes"; 296 var temp; 297 // Iterates through the field to check each character is numeric or not 298 for (var i=0; i<field.value.length; i++) 299 { 300 temp = "" + field.value.substring(i, i+1); 301 // If any character is non-numeric assigns "no" to ok 302 if (valid.indexOf(temp) == "-1") ok = "no"; 303 304 } 305 306 // If ok equals "yes" returns true 307 // Otherwise returns false 308 if (ok == "yes") 309 { 310 var hr=field.value; 311 var st = new String(hr); 312 var i = st.indexOf("."); 313 if (i == field.value.length - 1) { 314 alert("Invalid "+name+" :Should be of 0000.00 format"); 315 field.focus(); 316 return false; 317 } 318 if (i > 4) { 319 alert("Invalid "+name+" :Should be of 0000.00 format"); 320 field.focus(); 321 return false; 322 } 323 var mm=st.substring(i+1,hr.length); 324 mm = trim(mm); 325 if(mm.length == 1){ 326 mm = "0" + mm; 327 } 328 var m=parseInt(mm); 329 var hh=''; 330 if (i==4){ 331 hh=st.substring(0,4); 332 } 333 hh = trim(hh); 334 if (i==1){ 335 hh=st.substring(0,1); 336 hh = "000" + hh; 337 } 338 if (i==2){ 339 hh=st.substring(0,2); 340 hh = "00" + hh; 341 } 342 if (i==3){ 343 hh=st.substring(0,3); 344 hh = "0" + hh; 345 } 346 var h=parseInt(hh); 347 348 field=hh+'.'+mm; 349 350 field1 = field; 351 if ((field1.indexOf(".") == (field1.length-1)) && (field1 != "")) { 352 alert("Invalid "+name+" :Should be of 0000.00 format"); 353 isValidField = "false"; 354 field.focus(); 355 return false 356 } 357 if (field1.indexOf(".") == -1 && field.length > 4) { 358 alert("Invalid "+name+" :Should be of 0000.00 format"); 359 isValidField = "false"; 360 field.focus(); 361 return false 362 } 363 if (field1.indexOf(".") == 0 && field.length > 5) { 364 alert("Invalid "+name+" :Should be of 0000.00 format"); 365 isValidField = "false" ; 366// field.focus(); 367 return false 368 } 369 // Checks if session rate is a whole number and within the given range 370 if (field1.indexOf(".") == -1 && isValidField == "true") { 371 // If field is not empty then adds ".0" to field 372 if (field != "") { 373 field.value += ".00"; 374 } 375 // Otherwise sets the focus to field field 376 else { 377 field.focus(); 378 } 379 return true 380 } 381 382 if (field1.indexOf(".") == 0 && isValidField == "true") { 383 // If field is not empty then adds "0." to field 384 if (field != "") { 385 field.value = "00" + field.value; 386 } 387 // Otherwise sets the focus to session rate field 388 else { 389 field.focus(); 390 } 391 return true 392 393 } 394 if(field1 <= "9999.99"){ 395 return true 396 } 397 }else{ 398 alert("Invalid "+name+" :Should be of 0000.00 format"); 399 field.focus(); 400 return false 401 } 402 } 403 // This function validates levy amount value 404 function checkLevyAmount(field) { 405 var amount = field.value; 406 var isValidAmount = "true"; 407 var fieldPaymentAmount = trim(field.value); 408 // Checks if levy amount length is not equals zero 409 if(fieldPaymentAmount.length != 0){ 410 // Checks if levy amount is not a number then send an alert message and sets focus to this field 411 if (isNaN(amount)) { 412 alert("levy Amount should be numeric"); 413 isValidAmount = "false"; 414 return isValidAmount; 415 } 416 // Checks if levy amount is less than 0 and greater than equals 10000 417 if (parseFloat(amount) < 0 || parseFloat(amount) >= 10000) { 418 alert("levy Amount should be between 0 to 9999.99"); 419 isValidAmount = "false"; 420 return isValidAmount; 421 } 422 // Checks if levy amount is not a valid float value 423 // then sends an alert message and sets focus to this field 424 if ((amount.indexOf(".") == 0 || amount.indexOf(".") == (amount.length-1)) && (amount != "")) { 425 alert("Invalid levy Amount"); 426 isValidAmount = "false"; 427 return isValidAmount; 428 } 429 // Checks if levy amount is a whole number and within the given range 430 if (amount.indexOf(".") == -1 && isValidAmount == "true") { 431 if (amount != "") { 432 field.value += ".00"; 433 434 }else { 435 field.focus(); 436 } 437 return isValidAmount; 438 } 439 return isValidAmount; 440 } 441 } 442 443 // Function to validate and format time value as HH:MM AM/PM 444 function validateTime(timeField) { 445 var time = trim(timeField.value); 446 var timeLength = time.length; 447 var hrs = ""; 448 var mns = ""; 449 var clnIndex = ""; 450 var space = ""; 451 var isProperFormat = 0; 452 // If time length is not equals 0 then gets colon index and space index 453 if (timeLength != 0) { 454 clnIndex = time.indexOf(":"); 455 space = time.indexOf(" "); 456 // If time length is greater than 5 and space index is not -1 457 if (timeLength > 5 && space != -1) { 458 isProperFormat = 1; 459 // Gets am/pm value from the given time 460 var ampm = time.substring(space+1, space+3); 461 // Sets time value without am/pm 462 time = time.substring(0,space); 463 timeLength = time.length;
464 // Checks if ampm value is not valid then 465 // sends an alert message 466 // sets focus to time field 467 // and returns false 468 if ((ampm != "AM" && ampm != "PM") && (ampm != "am" && ampm != "pm")) { 469 alert("Please enter a valid time format"); 470 timeField.focus(); 471 return false; 472 } 473 }else if (timeLength > 5 && space == -1){ 474 alert("Please enter a valid time"); 475 timeField.focus(); 476 return false; 477 } 478 } 479 480 // Checks if space index equals -1 and time length is greater than 0 481 if (space == -1 && timeLength > 0) { 482 if (clnIndex != -1) { 483 hrs = time.substring(0, clnIndex); 484 mns = time.substring(clnIndex+1, timeLength); 485 }else { 486 hrs = time.substring(0, 2); 487 mns = time.substring(2, 4); 488 } 489 // Checks hours and minutes value for nonnumeric then 490 // sets the focus to time field and returns false 491 if (!checkNumericHrsMns(hrs, mns)) { 492 timeField.focus(); 493 return false; 494 } 495 } 496 497 // switch to particular case depending on the timeLength 498 switch (timeLength) { 499 // If time length is 1 500 case 1: // Adds "0" to time value and sets to hours 501 // Sets minutes as "00" 502 hrs = "0" + trim(time); 503 mns = "00"; 504 // Checks if hours and minutes values are numeric 505 // then formats the time value to standard format 506 if (checkNumericHrsMns(hrs, mns)) { 507 properTime(hrs, mns, timeField, isProperFormat, ampm); 508 } 509 // Otherwise sets focus to time field and returns false 510 else { 511 timeField.focus(); 512 return false; 513 } 514 break; 515 516 // If time length is 2 517 case 2: // Sets time value to hours 518 // Sets "00" to minutes 519 hrs = trim(time.substring(0,2)); 520 mns = "00"; 521 // Checks if hours and minutes values are numeric 522 // then formats the time value to standard format 523 if (checkNumericHrsMns(hrs, mns)) { 524 properTime(hrs, mns, timeField, isProperFormat, ampm); 525 } 526 // Otherwise sets focus to time field and returns false 527 else { 528 timeField.focus(); 529 return false; 530 } 531 break; 532 533 // If time length is 3 534 case 3: // Checks if colon index is -1 535 if (clnIndex != -1) { 536 // Sets a pattern for 2 digits 537 var patt = /\d{2}/; 538 // Gets hours and minutes value from time 539 hrs = trim(time.substring(0, clnIndex)); 540 mns = trim(time.substring(clnIndex+1, clnIndex+2)); 541 // Checks if hours and minutes values are numeric 542 if (checkNumericHrsMns(hrs, mns)) { 543 // Checks if hours value is not 2 digits then adds "0" before hours value 544 if (!patt.test(hrs)) { 545 hrs = "0" + hrs; 546 } 547 // Checks if minutes value is not 2 digits then adds "0" before minutes value 548 if (!patt.test(mns)) { 549 mns = "0" + mns; 550 } 551 } 552 // Checks if hours and minutes values are not numeric then sets focus to time field 553 // and returns false 554 else { 555 timeField.focus(); 556 return false; 557 } 558 } 559 // If time value does not contain colon 560 else { 561 // Sets a pattern for 2 digits 562 var patt = /\d{2}/; 563 // Gets hours and minutes value from time 564 hrs = trim(time.substring(0, 1)); 565 mns = trim(time.substring(1, 3)); 566 // Checks if hours and minutes values are numeric 567 if (checkNumericHrsMns(hrs, mns)) { 568 // Checks if hours value is not 2 digits then adds "0" before hours value 569 if (!patt.test(hrs)) { 570 hrs = "0" + hrs; 571 } 572 // Checks if minutes value is not 2 digits then adds "0" before minutes value 573 if (!patt.test(mns)) { 574 mns = "0" + mns; 575 } 576 } 577 // Checks if hours and minutes values are not numeric then sets focus to time field 578 // and returns false 579 else { 580 timeField.focus(); 581 return false; 582 } 583 } 584 // Calls properTime function to format the time with standard format 585 properTime(hrs, mns, timeField, isProperFormat, ampm); 586 break; 587 // If time length is 4 588 case 4: // Checks if colon index is -1 589 if (clnIndex != -1) { 590 // Sets a pattern for 2 digits 591 var patt = /\d{2}/; 592 // Gets hours and minutes value from time 593 hrs = trim(time.substring(0, clnIndex)); 594 mns = trim(time.substring(clnIndex+1, clnIndex+3)); 595 // Checks if hours and minutes values are numeric 596 if (checkNumericHrsMns(hrs, mns)) { 597 // Checks if hours value is not 2 digits then adds "0" before hours value 598 if (!patt.test(hrs)) { 599 hrs = "0" + hrs; 600 } 601 // Checks if minutes value is not 2 digits then adds "0" before minutes value 602 if (!patt.test(mns)) { 603 mns = "0" + mns; 604 } 605 } 606 // Checks if hours and minutes values are not numeric then sets focus to time field 607 // and returns false 608 else { 609 timeField.focus(); 610 return false; 611 } 612 } 613 // If time value does not contain colon 614 else { 615 // Gets hours and minutes value from time 616 hrs = trim(time.substring(0, 2)); 617 mns = trim(time.substring(2, 4)); 618 // Checks if hours and minutes values are not numeric then sets focus to time field 619 // and returns false 620 if (!checkNumericHrsMns(hrs, mns)) { 621 timeField.focus(); 622 return false; 623 } 624 } 625 // Calls properTime function to format the time with standard format 626 properTime(hrs, mns, timeField, isProperFormat, ampm); 627 break; 628 // If time length is 5 629 case 5: // Checks if colon index is -1 630 if (clnIndex != -1) { 631 // Gets hours and minutes value from time 632 hrs = trim(time.substring(0, clnIndex)); 633 mns = trim(time.substring(clnIndex+1, clnIndex+3)); 634 // Checks if hours and minutes values are numeric 635 // then formats the time value to standard format 636 if (checkNumericHrsMns(hrs, mns)) { 637 properTime(hrs, mns, timeField, isProperFormat, ampm); 638 } 639 // Checks if hours and minutes values are not numeric then sets focus to time field 640 // and returns false 641 else { 642 timeField.focus(); 643 return false; 644 } 645 } 646 // If time value does not contain colon then sends an alert message, sets focus to time field 647 // and returns true 648 else { 649 alert("Please enter a valid time format"); 650 timeField.focus(); 651 return false; 652 } 653 654 break; 655 } 656 657 658 } 659 660 // Function checks numeric value for hours and minutes 661 function checkNumericHrsMns(hrs, mns) { 662 // Checks if hours value is not a number then sends an alert message and returns false 663 if (isNaN(hrs)) { 664 alert ("Invalid time. Please enter number."); 665 return false; 666 } 667 // Checks if minutes value is not a number then sends an alert message and returns false
668 else if (isNaN(mns)) { 669 alert ("Invalid time. Please enter number."); 670 return false; 671 } 672 // Otherwise returns true 673 return true; 674 } 675 676 // Function converts hours and minutes value to proper format 677 function properTime(hrs, mins, timeField, isProperFormat, ampm) { 678 // Checks if minutes value is greater than 60 or hours value is greater than 12 and hours equals "00" 679 // then alerts a message, sets focus to time field and returns false 680 if ((mins >= 60) || (hrs > 23.59)) { 681 alert("Please enter a valid time"); 682 timeField.focus(); 683 return false; 684 } 685 else if(hrs == '00'){ 686 687 if(mins < 0){ 688 alert("Mins: "+mins); 689 alert("Please enter a valid time:Time Should Not be < 00:00"); 690 timeField.focus(); 691 return false; 692 } 693 else{ 694 timeField.value = hrs + ":" + mins ; 695 } 696 } 697 else { 698 699 timeField.value = hrs + ":" + mins ; 700 // Checks if hours value is 12 or hours value is greater than 0 and less than 7 701 /*if ((hrs == '12') || (hrs > '00' && hrs < '07')) { 702 // Checks if user entered am/pm value 703 // formats the time value with the given am/pm 704 if (isProperFormat == 1) { 705 timeField.value = hrs + ":" + mins + " " + ampm; 706 } 707 // Otherwise sets the time value with "PM" 708 else { 709 timeField.value = hrs + ":" + mins + " PM"; 710 } 711 }*/ 712 // Checks if hours value is greater than 7 and less than 12 713 /*if (hrs >= '07' && hrs < '12') { 714 // Checks if user entered am/pm value 715 // formats the time value with the given am/pm 716 if (isProperFormat == 1) { 717 timeField.value = hrs +":" + mins + " " + ampm; 718 } 719 // Otherwise sets the time value with "AM" 720 else { 721 timeField.value = hrs + ":" + mins + " AM"; 722 } 723 }*/ 724 } 725 726 } 727 // Function to validate Operations Days of a Service 728 function validateOperationsDay(field) 729 { 730 //field=field.toUpperCase(); 731 var checkOK = "YN" ; 732 var checkStr = field.value; 733 var allValid = true; 734 if(checkStr.length = 7) 735 { 736 for (i = 0; i < 7; i++) 737 { 738 ch = checkStr.charAt(i); 739 for (j = 0; j < checkOK.length; j++) 740 if (ch == checkOK.charAt(j)) 741 break; 742 if (j == checkOK.length) 743 { 744 allValid = false; 745 break; 746 } 747 748 } 749 } 750 else 751 { 752 allValid = false; 753 } 754 /* else 755 { 756 allValid = false; 757 } 758 */ 759 /* if (!allValid) 760 { 761 //field.focus(); 762 alert("Invalid data: should be in YN format"); 763 } 764 */ 765 return allValid; 766 } 767 768 769 // This function compares the given two dates ( b > a) 770 function startDateCompare(a, b) 771 { 772 b.value = trim(b.value); 773 // Checks if second date length is more than zero 774 if (b.value.length > 0) 775 { 776 var fromDate = new Date(convertDateFormat(a.value)); 777 var toDate = new Date(convertDateFormat(b.value)); 778 // Gets time difference of both the dates 779 diff = toDate.getTime() - fromDate.getTime(); 780 diff = Math.floor(diff / (1000 * 60 * 60 * 24) ); 781 // Checks if difference is more than zero then returns true 782 if (diff > 0) 783 { 784 return true; 785 } 786 // Otherwise returns false and sets focus to second date field 787 else 788 { 789 790 return false; 791 } 792 } 793 // If second date length is zero then returns true 794 else 795 { 796 return true; 797 } 798 } 799 800 //// This function compares the given two dates ( b >= a) 801 function startDateCompareForEqual(a, b) 802 { 803 b.value = trim(b.value); 804 // Checks if second date length is more than zero 805 if (b.value.length > 0) 806 { 807 var fromDate = new Date(convertDateFormat(a.value)); 808 var toDate = new Date(convertDateFormat(b.value)); 809 // Gets time difference of both the dates 810 diff = toDate.getTime() - fromDate.getTime(); 811 diff = Math.floor(diff / (1000 * 60 * 60 * 24) ); 812 // Checks if difference is more than zero then returns true 813 if (diff >= 0) 814 { 815 return true; 816 } 817 // Otherwise returns false and sets focus to second date field 818 else 819 { 820 //b.focus(); 821 return false; 822 } 823 } 824 // If second date length is zero then returns true 825 else 826 { 827 return true; 828 } 829 } 830 831 //This function compares the given two dates (-2:invalid , -1: b < a , 0: b = a, 1: b > a ) 832 function compareDate(a, b){ 833 //b = trim(b); 834 //Checks if second date length is more than zero 835 if (a.length > 0 && b.length > 0 ) { 836 var fromDate = new Date(convertDateFormat(a)); 837 var toDate = new Date(convertDateFormat(b)); 838 //Gets time difference of both the dates 839 diff = toDate.getTime() - fromDate.getTime(); 840 diff = Math.floor(diff / (1000 * 60 * 60 * 24) ); 841 //0: b = a 842 if(diff == 0) { 843 //alert(" b = a "); 844 return 0; 845 } 846 //1: b > a 847 else if(diff > 0) { 848 //alert(" b > a "); 849 return 1; 850 } 851 //-1: b < a 852 else if(diff < 0) { 853 //alert(" b < a "); 854 return -1; 855 } 856 //-2:invalid 857 else{ 858 return -2; 859 } 860 } 861 //-2:invalid 862 else{ 863 return -2; 864 } 865 }//End of 'function DateCompareForEqual(a, b){' 866 //function to convert the given dd/mm/yyyy date format to mm/dd/yyyy date format 867 function convertDateFormat(ddmmyy){ 868 var dd = ddmmyy.substring(0,2); 869 var mm = ddmmyy.substring(3,5); 870 var yy = ddmmyy.substring(6,10); 871 872 var mmddyy = mm + '/' + dd + '/' + yy; 873 return mmddyy; 874 } 875 876 //Function to Check whether the given date is less than the Current Date 877 function currentDateCompare(a) { 878 //Getting Current Date 879 var d = new Date(); 880 //Getting Current Day 881 var curr_day = d.getDay(); 882 var curr_date = d.getDate(); 883 //Getting Current Month 884 var curr_month = d.getMonth()+1; 885 //Getting Current Year 886 var curr_year = d.getFullYear(); 887 888 889 flag=true; 890 891 a.value = trim(a.value); 892 toDate=trim(a.value); 893 894 y1=curr_year; 895 m1=curr_month; 896 d1=curr_date; 897 898 y2=toDate.substring(6,10); 899 m2=toDate.substring(3,5); 900 d2=toDate.substring(0,2); 901 902 //Converting to mm/dd/yyyy format 903 fromDate= m1 + '/' + d1 + '/' + y1; 904 toDate= m2 + '/' + d2 + '/' + y2; 905 var fromDate1 = new Date(fromDate); 906 var toDate1 = new Date(toDate); 907 908 //alert("Current Date :"+fromDate1+" , Given Date : "+toDate1); 909 diff = toDate1.getTime() - fromDate1.getTime(); 910 diff = Math.floor(diff / (1000 * 60 * 60 * 24) ); 911 912 // Checks if difference is more than or equalto zero then returns true 913 if (diff >= 0) 914 { 915 flag=true; 916 } 917 // Otherwise returns false and sets focus to second date field 918 else 919 { 920 //a.focus(); 921 flag=false; 922 } 923 924 return flag; 925 } 926 //Checking for valid alphabet with space 927 function isValidAlphabetsWithSpace(field) 928 { 929 sText=field.value; 930 var flag=true;
931 var validAlphabets = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 932 933 var char1; 934 for(i = 0; i < sText.length ; i++) 935 936 { 937 char1 = sText.charAt(i); 938 if (validAlphabets.indexOf(char1) == -1) 939 { 940 flag = false; 941 } 942 } 943 return flag; 944 } 945 //Checking for valid alphaNumeric with space 946 function isValidAlphaNumericWithSpace(field) 947 { 948 sText=field.value; 949 var flag=true; 950 var validAlphabets = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 951 952 var char1; 953 for(i = 0; i < sText.length ; i++) 954 955 { 956 char1 = sText.charAt(i); 957 if (validAlphabets.indexOf(char1) == -1) 958 { 959 flag = false; 960 } 961 } 962 return flag; 963 } 964 //Checking for valid alphaNumeric with space 965 function isValidAlphaNumericWithOutSpace(field) 966 { 967 sText=field.value; 968 var flag=true; 969 var validAlphabets = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 970 971 var char1; 972 for(i = 0; i < sText.length ; i++) 973 974 { 975 char1 = sText.charAt(i); 976 if (validAlphabets.indexOf(char1) == -1) 977 { 978 flag = false; 979 } 980 } 981 return flag; 982 } 983 //Common Name Validation for Corporation,Division,Depot,Busstand ,Counter, Place , Area,Pickup Point Masters 984 function isValidName(field) 985 { 986 sText=field.value; 987 var flag=true; 988 var validAlphabets = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890()-_[]{};./"; 989 990 var char1; 991 for(i = 0; i < sText.length ; i++) 992 993 { 994 char1 = sText.charAt(i); 995 if (validAlphabets.indexOf(char1) == -1) 996 { 997 flag = false; 998 } 999 } 1000 return flag; 1001 } 1002 //Function to Check whether the given date is less than the Current Date 1003 function currentDateAndEffectveDateCompare(effDate) 1004 { 1005 //Getting Current Date 1006 var d = new Date(); 1007 //Getting Current Day 1008 var curr_day = d.getDay(); 1009 var curr_date = d.getDate(); 1010 //Getting Current Month 1011 var curr_month = d.getMonth()+1; 1012 //Getting Current Year 1013 var curr_year = d.getFullYear(); 1014 1015 1016 flag=true; 1017 1018 toDate=trim(effDate); 1019 1020 y1=curr_year; 1021 m1=curr_month; 1022 d1=curr_date; 1023 1024 y2=toDate.substring(6,10); 1025 m2=toDate.substring(3,5); 1026 d2=toDate.substring(0,2); 1027 1028 //Converting to mm/dd/yyyy format 1029 fromDate= m1 + '/' + d1 + '/' + y1; 1030 toDate= m2 + '/' + d2 + '/' + y2; 1031 1032 var fromDate1 = new Date(fromDate); 1033 var toDate1 = new Date(toDate); 1034 1035 //alert("Current Date :"+fromDate1+" , Given Date : "+toDate1); 1036 diff = toDate1.getTime() - fromDate1.getTime(); 1037 diff = Math.floor(diff / (1000 * 60 * 60 * 24) ); 1038 1039 1040 // Checks if difference is more than or equalto zero then returns true 1041 if (diff > 0) 1042 { 1043 flag=true; 1044 } 1045 // Otherwise returns false and sets focus to second date field 1046 else 1047 { 1048 //a.focus(); 1049 flag=false; 1050 } 1051 1052 return flag; 1053 } 1054 1055
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.