The simplest solution is a client-side one using Javascript.
In upload.php, change the open_form function to be as shown:
function open_form($path) {
echo <<<EOT
<script language="javascript" type="text/javascript">
function textCounter(field, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
}
function ValidateForm(form) {
title = form.title.value;
title = title.replace(/^\s*/, '').replace(/\s*$/, '');
if (title.length == 0) {
alert("You must enter a title."); // not language-compatible
form.title.focus();
return false;
}
return true;
}
</script>
<form method="post" action="$path" enctype="multipart/form-data" name="upload_form" onSubmit="javascript:return ValidateForm(this)">
EOT;
}
The changes are adding the ValidateForm function into the Javascript block and adding the name & onSubmit properties to the form tag. The form name is not actually necessary for this mod but I figured while we were changing things, it's a good idea to name the form. You might use it for something else.
If you want a language-compatible solution, you need to replace the text in the alert call to something language-compatible. The closest I could find was this:
alert('{$lang_thumb_view['submit']}'+' '+'{$lang_upload_php['pic_title']}');
and you have to add this line at the beginning of the open_form function:
global $lang_thumb_view, $lang_upload_php;
(before the echo <<<EOT line). There is a 'missing' string used in another script's $lang array, but it would require pretending to be that script to use that string so it's best to stick to the global & upload arrays.