Well we need to get the value of the input box first. So look at the source of the page, using Chrome right click on the input box and "inspect element".
Now you should see something similar to this:
<input id="po455" type="text" name="product_options[455]">
I'm sure you could do this a number of ways, but I am going to just use the input's id in order to reference this box in my JS.
var option = $('#po455').val();
This declares a variable, and names it "option", then sets it using a jQuery method of obtaining the value of the input by referencing it's id. So now we can refer to that value simply as option in our code.
Consider this code:
if (option != "funky") {
window.alert(option);
return false;
}
So now it is checking if the value of the input box matches the string "funky", if it doesn't then it alerts whatever the current value of the box is. If it is blank you should see nothing in the alert box, if you type "Whalah!" into the box it should alert that to you. The bottom line is that if it matches what you put between the braces () then it will perform what you put within the curly braces {}. And then it returns false, and the form is not submitted.
So to check if the box is empty, we would try something like:
if(option == '' or option == null) {
alert("Type something, you dope!");
return false;
}
