@ZeroKilledMay 11.2009 — #basically you use the [b]onsubmit[/b] event and have a function to validate the form. when the function detect a no valid data the function return boolean false to prevent for submission. <i> </i><form onsubmit="return checkform(this);"> <input type='text' name='user' /> ... </form>
function checkform(form){ if(!/^[a-z0-9]{3,}$/i.test(form.user.value))return false; return true; }
in this sample if there is no at least a sequence of three or more alphanumeric, the form doesn't submit.
@enchanceauthorMay 11.2009 — #Sorry, I find this hard to understand. I apologize, I haven't tried regexp yet. I want to know if only spaces were entered regardless of how many there are. that way I can prevent the form from sending. Any other character is ok.
@ZeroKilledMay 11.2009 — #well, the code is almost similar. however, regular expression is the more easier way to do it: <i> </i>function checkform(form){ return !/^s+$/.test(form.user.value); }
if you want to achieve it without regular expression, then you will have to check each char of the string, one by one, and match it to verify if it is a white space.