1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| <script type="text/javascript">
/*
Created by: Amit Wadhwa ::
*/
function checkThisForm(formname, submitbutton, errors) {
if (errors == '') {
eval(formname+'.'+submitbutton+'.disabled=true');
eval('document.'+formname+'.submit()');
} else {
alert(errors);
}
}
function checkText(formname, textboxname, displaytext) {
var localerror = '';
if(Trim(eval('document.'+formname+'.'+textboxname+'.value'))=='') {
localerror = '- '+displaytext+' sont requis.\n';
} else localerror = '';
return localerror;
}
function checkNum(formname, textboxname, displaytext) {
var localerror = '';
if(isNaN(eval('document.'+formname+'.'+textboxname+'.value'))) {
localerror = '- '+displaytext+' doit être des chiffres sans espaces.\n';
} else localerror = '';
return localerror;
}
function checkSpaces(formname, textboxname, displaytext) {
var valid = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'; // define valid characters
var localerror = '';
if(!isValid(Trim(eval('document.'+formname+'.'+textboxname+'.value')), valid)) {
localerror = '- '+displaytext+' Should Not Contain Spaces.\n';
} else localerror = '';
return localerror;
}
function checkSelect(formname, selectboxname, displaytext) {
var localerror = '';
if(eval('document.'+formname+'.'+selectboxname+'.selectedIndex')==0) {
localerror = '- '+displaytext+' est requis.\n';
} else localerror = '';
return localerror;
}
function getRadio(formname, radioname, displaytext) {
for (var i=0; i < eval('document.'+formname+'.'+radioname+'.length'); i++) {
if (eval('document.'+formname+'.'+radioname+'[i].checked')) {
var rad_val = eval('document.'+formname+'.'+radioname+'[i].value');
return rad_val;
}
}
}
function checkRadio(formname, radioname, displaytext) {
var localerror = '';
var rad_val = '';
for (var i=0; i < eval('document.'+formname+'.'+radioname+'.length'); i++) { //check every radio button by that name
if (eval('document.'+formname+'.'+radioname+'[i].checked')) { //if it is checked
rad_val += '-';
} else rad_val += '';
}
if (rad_val=='') {
localerror = '- '+displaytext+' est requis.\n';
}
return localerror;
}
function autoComplete (field, select, property) {
/*onKeyUp="autoComplete(this,this.form.selectboxname,'value',false)" - add this to textbox where you are typing*/
var found = false;
for (var i = 0; i < select.options.length; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
found=true; break;
}
}
if (found) {
select.selectedIndex = i;
} else {
select.selectedIndex = -1;
}
if (field.createTextRange) {
if (!found) {
field.value=field.value.substring(0,field.value.length-1);
return;
}
var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
if (cursorKeys.indexOf(event.keyCode+";") == -1) {
var r1 = field.createTextRange();
var oldValue = r1.text;
var newValue = found ? select.options[i][property] : oldValue;
if (newValue != field.value) {
field.value = newValue;
var rNew = field.createTextRange();
rNew.moveStart('character', oldValue.length) ;
rNew.select();
}
}
}
}
function Trim(s) {
while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) {
s = s.substring(1,s.length);
}
while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) {
s = s.substring(0,s.length-1);
}
return s;
}
function isValid(string,allowed) {
// var valid = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; // define valid characters
for (var i=0; i< string.length; i++) {
if (allowed.indexOf(string.charAt(i)) == -1) return false;
}
return true;
}
</script>
<script type="text/javascript">
<!--
/*
Created by: Amit Wadhwa ::
*/
function check(formname, submitbutton) {
var errors = '';
errors += checkSelect(formname, 'from', 'Select a departure please');
checkThisForm(formname, submitbutton, errors);
}
//-->
</script>
<form name="formulaire_resa" method="POST" action="index2.php">
<p>Entrez votre pays de résidence:
<select name="from" id="from" onChange="javascript:tester_paiement();">
<option value="" selected>- Choose a departure -</option>
<option value="Paris">Paris</option>
<option value="Disneyland">Disneyland</option>
<option value="L'Aéroport Charles de Gaulle">Charles de Gaulle Aeroport</option>
<option value="L'Aéroport Orly">Orly Aeroport</option>
<option value="L'Aéroport Beauvais">Beauvais Aeroport</option>
<option value="Dep_Adresse">Other</option>
</select>
<input type="image" src="show_prices.png" alt="ok" onClick="check('formulaire_resa', this.name);"></p>
</form> |
Partager