Monday 2 January 2012

How to trim customer login password in magento (or) Avoid white space in magento customer login page

Goto -> app/design/frontend/default/User_Theme/template/customer/form/login.phtml


add the following javascript


<script type="text/javascript">

// Removes leading whitespaces
function LTrim( testUrl)
{       
          var re = /\s*((\S+\s*)*)/;
          return testUrl.replace(re, "$1");
         
}
// Removes ending whitespaces
 
function RTrim( testUrl)
{       
          var re = /((\s*\S+)*)\s*/;
          return testUrl.replace(re, "$1");      
}
 
 
// Removes leading and ending whitespaces
function trim()
{

    document.getElementById('pass').value = LTrim(RTrim(document.getElementById('pass').value));
    return true;
}
</script>



and call that function in that form page




<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="login-form" onsubmit="javascript:trim();">

using this  we can avoid password white space in leading and ending of the password give in customer login page in magento







No comments:

Post a Comment