Check if form is touched
<p>In angular I want to do this</p>

<pre><code>&lt;script&gt;
  //inside the controller
  $scope.myForm.$dirty{
    //hide some divs etc.
  }
&lt;/script&gt;
</code></pre>

<p>How can I do this only in JavaScript, without putting any of the validation in my HTML?</p>

<p><strong>update</strong></p>

<pre><code>&lt;form id="loginform" name="loginform" ng-submit="login()" novalidate&gt;
&lt;input type="text" class="form-control" id="username" name="username" ng-model="username" ng-click="hideInvalidUsername()" placeholder="Username" autofocus required&gt;

&lt;/form&gt;
</code></pre>

<p>and in my controller</p>

<pre><code>  app.controller('myCtrl', ['$scope', 'localStorageService' ,
  function ($scope, localStorageService ) {  

if($scope.loginform.$dirty) { alert("yo"); }
</code></pre>