validation not working for js
<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form class="form-horizontal cmxform" id="validateForm" method="get" action="../../course_controller" autocomplete="off"&gt;


&lt;input type="text" id="course_name" name="course_name" placeholder="Enter Course Name..." class="row-fluid" required onkeyup="javaScript:validate_course_name();"&gt;
&lt;label id="course_name_info" style="color:rgba(255,255,255,0.6);font-size:13px"&gt;
&lt;/label&gt;



&lt;button type="submit" name="user_action" value="add" class="btn btn-primary" onClick="javaScript:validate();" &gt;Save&lt;/button&gt;
&lt;button type="reset" class="btn btn-secondary"&gt;Cancel&lt;/button&gt;



&lt;/form&gt;
&lt;script type="text/javascript"&gt;
/**** Specific JS for this page ****/

//Validation things




function validate_course_name(){

var TCode = document.getElementById('course_name').value;

if( /[^a-zA-Z1-9 _-]/.test( TCode ) ) {

course_name_info.innerHTML="Please Enter Only Alphanumeric or _,-,' ' ";
return false;
}
else
{
course_name_info.innerHTML=" ";
return true;
}


}
function validate(){


validate_course_name();

}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>So this the code ...I am applying alpha numeric validation on one field but even if i give invalid input like some other characters the form is getting submitted where am i doing it wrong?
i am very new to this web so any help will be appreciated:)</p>
