1// JavaScript Document 2function validateForm() { 3 var fname = document.getElementById('fname').value; 4 var lname = document.getElementById('lname').value; 5 var gender = valButton(document.getElementsByName('gender')); 6 var frmMonth = document.getElementById('frmMonth').value; 7 var frmDay = document.getElementById('frmDay').value; 8 var frmYear = document.getElementById('frmYear').value; 9 var birthplace = document.getElementById('birthplace').value; 10 var country = document.getElementById('country').value; 11 var nationality = document.getElementById('nationality').value; 12 13 // added agent fields 14 var frmYear1 = document.getElementById('frmYear1').value; 15 var fulltime = valButton(document.getElementsByName('fulltime')); 16 var fiba_license = valButton(document.getElementsByName('fiba_license')); 17 var nba_license = valButton(document.getElementsByName('nba_license')); 18 var represent = valButton(document.getElementsByName('represent')); 19 // end of agent fields 20 21 var reg = /^[0-9]+$/; 22 var numeric = /^ *[0-9]+ *$/; 23 24 if (fname == '') { 25 alert('Please enter first name'); 26 document.getElementById('fname').focus(); 27 return false; 28 }
28 else if (lname == '') { 29 alert('Please enter last name'); 30 document.getElementById('lname').focus(); 31 return false; 32 } else if (gender == null) { 33 alert('Please select gender'); 34 document.getElementById('gender').focus(); 35 return false; 36 } else if ( ! isValidDate(frmDay, frmMonth, frmYear ) ) { 37 alert('The date you entered is not a valid date') ; 38 document.getElementById('frmDay').focus(); 39 return false ; 40 } else if (birthplace == '') { 41 alert('Please enter place of birth'); 42 document.getElementById('birthplace').focus(); 43 return false; 44 } else if (country == '' || country == 0) { 45 alert('Please select country of birth'); 46 document.getElementById('country').focus(); 47 return false; 48 } else if (nationality == '' || nationality == 0) { 49 alert('Please select nationality'); 50 document.getElementById('nationality').focus(); 51 return false; 52 } 53 // add agent checks 54 else if (frmYear1 == '0') { 55 alert('Please select year where you start to work as an agent'); 56 document.getElementById('frmYear1').focus; 57 return false; 58 } else if (fulltime == null) { 59 alert('Please select Are you fulltime or part time agent?'); 60 return false; 61 } else if (fiba_license == null) { 62 alert('Please select Are you a FIBA licensed agent?'); 63 return false; 64 } else if (nba_license == null) { 65 alert('Please select Are you an NBA/WNBA licensed agent?'); 66 return false; 67 } 68 69} 70function valButton(btn) { 71 var cnt = -1; 72 for ( var i = btn.length - 1; i > -1; i--) { 73 if (btn[i].checked) { 74 cnt = i; 75 i = -1; 76 } 77 } 78 if (cnt > -1) 79 return btn[cnt].value; 80 else 81 return null; 82} 83function isValidDate(day, month, year) { 84 /* 85 * Purpose: return true if the date is valid, false otherwise 86 * 87 * Arguments: day integer representing day of month month integer 88 * representing month of year year integer representing year 89 * 90 * Variables: dteDate - date object 91 * 92 */ 93 var dteDate; 94 95 // set up a Date object based on the day, month and year arguments 96 // javascript months start at 0 (0-11 instead of 1-12) 97 month = month -1 ; 98 dteDate = new Date(year, month , day); 99 100 /* 101 * Javascript Dates are a little too forgiving and will change the date 102 * to a reasonable guess if it's invalid. We'll use this to our 103 * advantage by creating the date object and then comparing it to the 104 * details we put it. If the Date object is different, then it must have 105 * been an invalid date to start with... 106 */ 107 108 return ((day == dteDate.getDate()) && (month == dteDate.getMonth()) && (year == dteDate 109 .getFullYear())); 110}
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.