Hi,

I am new to this technology, I had created rules.js file in which i mentioned validate function which is used for required field validator for textarea. but after adding the js file in my html page i unable to call that function please let me know what i am doing wrong.


rules.js file

Code:
<script>
   
   function validate()
   {
      var req=document.forms["registration"]["comments"].value;
      
      if (req==null || req=="")
      {
         alert("");
         return false;
      }
   }
</script>
HTML Page

Code:
<script type="text/javascript" src="rules.js"></script>
Form Tag
Code:
<form id="registration" name="registration" method="POST" action="" onsubmit="return validate();">
If i add this function on the same HTML page, the after i don't face any problem to calling it, but i want to call it from source file.