Changing view from a controller in Sails.js

I simply want to print a sentence in part of a view file . But the controller decides for it. Here is my controller file loginController

login: function(req, res){
  var x = new LdapService();

  console.log('inside log in action') ;
  x.loginSuccessful(req.body.userid, req.body.password, function(isAuth){
      console.log(isAuth) ;
      if(isAuth )
          res.send('successful login');
      else
          res.render('login/index', document.getElementById("message").innerHTML = "Log in failde. Please check your Username or Password");
  });
},

I dont want to use jSon. I just want a javascript command is executed and prints a scentence in my view. But controller and login function should decide about it.

My view file:

<div class="form-group">
    <input type="password" name="password" class="form-control" placeholder="Password"/>    
    <br>
    <p id="message"></p>
    <br>
</div>       

It doesn't appear that you've read the documentation for views or view locals. It also looks like you're confusing back-end code (your Sails controller) with front-end code; things like document.getElementById are for manipulating the DOM on the front-end, after the browser has already rendered it.

What you want in your action instead of res.render is:

res.view('login/index', 
    {message: "Log in failed. Please check your Username or Password"}
);

and in your view:

<p id="message"><%=message%></p>

Note that EJS will throw an error if it encounters any unbound variables in a template, so every time you render the login view with res.view you'll have to set the message local, even if it's to an empty string.

You may also want to consider using flash messages for this sort of thing.