how could i  make the submit ,average and  reset button all disable until i enter a number between -9999 to 9999

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

 in a html code like this 

---------------------------

<!DOCTYPE html>

<html>

<head>

<link rel="stylesheet" href="1.css">

<script src="1.js"></script>

<title>Temperature Converter </title>

</head>

<body>

<h1 id="title"> Temperature Converter </h1>

<p> Convert from Fahrenheit to Celsius</p>

<div class="sidebyside">

<label>Fahrenheit</label>

<p> Enter Fahrenheit temperature </p>

<input id="fInputValue" onkeypress="return validate(event)" maxlength="10">

<button type="button" onclick="convertToC()">Submit</button>

<br>

<label>result Celsius: </label>

<p id="resultCValue">&nbsp;</p>

</div>

</br>

<div class="sidebyside" style="margin-top: 0px;border: none;">

<label>Result of the input </label>

</br>


<label>Fahrenheit</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<label>Celsius</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

</br>

</br>

<textarea id="dataHistory" "input type="text" value="dont input" readonly="readonly" name="dataHistory" rows="30" cols="35" style="margin-top: 10px;text-align: left;padding-top: 20px;padding-right: 0px;font-size: 18px;">

</textarea>

<span id="dataHistory"></span></br>

<span id="resultLine"></span></br>

<span id="totalAverage"></span>

</div>

</br>

<button type="button" onclick="clearHistory()" style="float: right:200;width: 90px;height: 35px;font-size: 17px;font-weight: bold;cursor: pointer;">Reset</button>

<button type="button" onclick="calcAverage()" style="float: right:290;width: 90px;height: 35px;font-size: 17px;font-weight: bold;cursor: pointer;">Average</button>

<div>

</div>

</body>

</html>

------

1.js

var arr1 = [];

function validate(evt) {

var theEvent = evt || window.event;

if (theEvent.type === 'paste')

{

key = event.clipboardData.getData('text/plain');

}

else {

var key = theEvent.keyCode || theEvent.which;

key = String.fromCharCode(key);

console.log(evt.target.value);

}

var regex = /^[+-]?[0-9.]{1,9}(?:\.[0-9]{1,2})?$/

if(theEvent.keyCode==45 && evt.target.value=="")

{return true;}

else{

if( !regex.test(key) )

{

theEvent.returnValue = false;

if(theEvent.preventDefault) theEvent.preventDefault();

}

}

}


function convertToC() {

let fValue = document.getElementById("fInputValue").value;

if(-9999<=fValue && fValue<=9999)

{

let cTemp = ((fValue - 32) / 1.8).toFixed(2);

document.getElementById("resultCValue").innerHTML = `= ${cTemp} C`;

document.getElementById("resultCValue").style.color='white';

loadArrayData(cTemp, fValue);

}

else{

document.getElementById("resultCValue").innerHTML = "Value should be between -9999 to 9999";

document.getElementById("resultCValue").style.color='red';

}

}

function loadArrayData(data, anotherData)

{

var oldValue = document.getElementById("dataHistory").innerHTML;

if((data != '' || data != null) && (anotherData != '' || anotherData != null))

{

arr1.push({

Celsius:data,

Fahrenheit:anotherData

});

}

for(i=0;i<arr1.length;i++)

{

document.getElementById("dataHistory").innerHTML = oldValue+"<br>"+arr1[i].Fahrenheit+ "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +arr1[i].Celsius+"\t";

}

document.getElementById("resultLine").innerHTML = "\t=============\n"

}

function calcAverage() {

const avgCel = (arr1.reduce((t,b) => {

return t + +b.Celsius

}, 0) / arr1.length).toFixed(2);

const avgFahr = (arr1.reduce((t,b) => {

return t + +b.Fahrenheit

}, 0) / arr1.length).toFixed(2);

var oldValue = document.getElementById("totalAverage").innerHTML;

document.getElementById("totalAverage").innerHTML = avgFahr+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+avgCel ;

}

function clearHistory()

{

arr1 = [];

document.getElementById("resultData").innerHTML = '';

document.getElementById("fInputValue").value = '';

document.getElementById("resultCValue").innerHTML = '';

}

-------------------

how could i  make the submit ,average and  reset button all disable until i enter a number between -9999 to 9999 ?

Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY