What is important is that you understand what Javascript can do - then finding a piece of code on the internet that will do what you want it to do. There is plenty of that available, and all that is required is for you to tweak such code.
For example, you find this script that checks for required fields, e.g. ensure that a specific field in the form is completed before the form is submitted:
Language: Javascript
<html>
<head>
<script type="text/javascript">
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if ( document.contact_form.contact_name.value == "" )
{
alert ( "Please fill in the ';Your Name'; box." );
valid = false;
}
return valid;
}
//-->
</script>
You just need to edit "document.contact_form.contact_name.value" to reflect your form's name and the text field, e.g if you form's name is myform and the field is name, you will change it to "document.myform.name.value "
These sites with the code normally explains step by step exactly what you have to add where in your html page.