convertDistance input cleaner
This commit is contained in:
		| @@ -55,6 +55,10 @@ header { | ||||
| .container { | ||||
|     padding-bottom: 25px; | ||||
| } | ||||
| #firstValue { | ||||
|     width: 25% !important; | ||||
|     display: inline; | ||||
| } | ||||
| .table { | ||||
|     color: white; | ||||
| } | ||||
|   | ||||
| @@ -97,19 +97,17 @@ $(function () { | ||||
|  | ||||
|     $("#submitConvertDistance").click(function()  | ||||
|     { | ||||
|         let firstValueEntered = $('#firstValue').val(); | ||||
|         let secondValueEntered = $("#secondValue option:selected").text(); | ||||
|         let firstValue = $('#firstValue').val(); | ||||
|         let unitFirstValue = $("#firstValueUnit option:selected").text(); | ||||
|         let secondValue = $("#secondValue option:selected").text(); | ||||
|  | ||||
|         if(isEmptyValue(firstValueEntered) || isEmptyValue(secondValueEntered)) | ||||
|         if(isEmptyValue(firstValue) || isEmptyValue(secondValue)) | ||||
|         { | ||||
|             $('.results').html(emptyMessageError); | ||||
|         } | ||||
|         else  | ||||
|         { | ||||
|             let firstValue = parseFloat(firstValueEntered.slice(0, firstValueEntered.length - 2));; | ||||
|             let unitFirstValue = firstValueEntered.slice(firstValueEntered.length - 2); | ||||
|  | ||||
|             let result = convertDistance(firstValue, unitFirstValue, secondValueEntered); | ||||
|             let result = convertDistance(parseFloat(firstValue), unitFirstValue, secondValue); | ||||
|             if(result === messageError) | ||||
|             { | ||||
|                 $('.results').html(messageError); | ||||
|   | ||||
| @@ -10,9 +10,25 @@ | ||||
|   <p class="pt-3 text-center"><?php echo $description?></p> | ||||
|   <br> | ||||
|   <div class="form-group"> | ||||
| 		<label for="firstValue">Entrez la distance que vous voulez convertir :</label> | ||||
|         <input name="firstValue" type="text" id="firstValue" placeholder="(e.g : 50cm)" class="form-control"> | ||||
|         <label for="firstValue">Entrez la distance que vous voulez convertir et sélectionner l'unité de celle-çi :</label> | ||||
|         <br> | ||||
|         <input name="firstValue" type="text" id="firstValue" placeholder="(e.g : 50)" class="form-control"> | ||||
|         <select id="firstValueUnit"> | ||||
|             <option value="pm">pm</option> | ||||
|             <option value="nm">nm</option> | ||||
|             <option value="µm">µm</option> | ||||
|             <option value="mm">mm</option> | ||||
|             <option value="cm">cm</option> | ||||
|             <option value="dm">dm</option> | ||||
|             <option value="m">m</option> | ||||
|             <option value="dam">dam</option> | ||||
|             <option value="hm">hm</option> | ||||
|             <option value="km">km</option> | ||||
|             <option value="Mm">Mm</option> | ||||
|             <option value="Gm">Gm</option> | ||||
|             <option value="Tm">Tm</option> | ||||
|         </select> | ||||
|         <br> <br> | ||||
| 		<label for="secondValue">Choisissez l'unité que vous voulez avoir après conversion :</label> <br> | ||||
|         <select id="secondValue"> | ||||
|             <option value="pm">pm</option> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user