javascript - blank space validation
<pre><code>function validation(reg) {
    str = document.reg;
    if (str.name.value == "") {
        alert("Enter your name");
        str.name.focus();
        return false;
    }
</code></pre>

<p>Validation will working fine if input is empty. </p>

<p>Problem</p>

<ol>
<li>User can enter a blank space on the first.</li>
<li>Also user can enter space only on the name.</li>
</ol>

<p>How to prevent it?</p>
