Forum Moderators: open
<form name="myForm" method="get" onsubmit="return emptyValidation(usage,"Please enter a value!")">
<input type="text" name="usage">
<input type="submit" name="go" value="go">
</form>
1. Bad quote nesting.
2. Reference, usage, enough.
Try:
onsubmit="return emptyValidation(this.usage,'Please enter a value!')" I don't like 'with', it's confusing. How about:
function emptyValidation(entered,alertbox)
{
var value = entered.value;
if(!value)// empty string is false
{
if(alertbox)
alert(alertbox);
return false;
}
else return true;
}// or // simply..
function emptyValidation(entered,alertbox)
{
if(alertbox &&!entered.value) alert(alertbox);
return!entered.value;
}
Oh the online editor again!
The line line should read:
return[space][excl!][excl!]entered.value;
<form name="myForm" method="get" onsubmit="return emptyValidation(this.usage,"Please enter a value!")">
<input type="text" name="usage" size=3>
<input type="submit" name="go" value="go">
</form>