How can i create form validation for the textbox inputs to display and error message?

errormsg

[codebyte]
if ($("#to_fahrenheit" ).checked)

{

    let convertCelsius = parseFloat($("#degrees_entered").value);

    var fahrenheit = convertCelsius* 9/5 + 32;

    $("#degrees_computed").value = fahrenheit.toFixed(0);

}

 else

 {

    let convertFahrenheit = parseFloat($("#degrees_entered").value);

    var celsius = (convertFahrenheit -32) * 5/9;

    $("#degrees_computed").value = celsius.toFixed(0);
 }

};

[codebyte]