You need to sign in to do that
Don't have an account?
Where do I start to redirect the customer portal login form if login fails?
Im trying to get to the end result of the form and change it before it submits, so that if the form would send the user to the failure page, instead I can send the user to my own custom failure page.
Is this possible? Here is what I am trying but it is not working.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script type="text/javascript"> <!-- function changeForm() { var user_name = document.forms[0].un.value; var user_password = document.forms[0].pw.value; var form_result = document.forms[0].action; if (user_name=="") { alert('Missing username'); return false; } else if (user_password=="") { alert('Missing password'); return false; } else if (form_result=="https://na3.salesforce.com/secur/login_portal.jsp") { alert('Username and/or Pasword are incorrect'); return false; } return true; } // --> </script> <title></title> </head> <body> <div> <!-- start login form --> <form name="login" action= "https://na3.salesforce.com/secur/login_portal.jsp" method= "post" base_target="_top" id="login" onsubmit= "return changeForm()"> <input type="hidden" name="startURL" value=""> <input type="hidden" name="loginURL" value=""> <input type="hidden" name="useSecure" value="true"> <input type="hidden" name="jse" id="jse" value="0"> <input type="hidden" name="orgId" value= "xxxxxxxxxxxxxxx"><input type="hidden" name="portalId" value="xxxxxxxxxxxxxxx"> <input type="hidden" name= "loginType" value="2"> <input type="hidden" name="action" value="loginAction"> <table summary="" width="100%" border="1"> <tr> <td> <label for="un">Username:</label> </td> <td> <input autocomplete="on" type="text" name="un" size="25" maxlength="80" value="" class="username"> </td> </tr> <tr> <td> <label for="pw">Password:</label> </td> <td> <input autocomplete="on" type="password" id= "password" name="pw" size="25" maxlength="80" class="pw"> </td> </tr> <tr> <td colspan="2"> <input type="submit" class="btn" value="Login"> </td> </tr> </table> </form> </div> </body> </html>
Thank you prageeth ,
I can get to the action of the form using your syntax
Syntax = document.forms['formName'].elements['elementName'].value;
Syntax = document.forms['formName'].action;
I think what I am trying to do is get the returned URL from the server and control a page redirect depending on what the server returns. So I prevent the user going to the servers 'login failed' page and instead go to mine.
Is this something I can only do server side?
( I think you meant "I can't " instead of "I can".
I can get to the action of the form using your syntax )
Sometimes I may haven't understood you correctly.
However you can access the form action as below.
var form_result = document.forms['login'].getAttribute('action');
Thank you prageeth
Yes your right this works
var form_result = document.forms['login'].getAttribute('action');
Do you know if I can redirect the user to a different page if 'form_result' returns a certain url? Can this only be done server side, to redirect the user based on the ending result of the for submit action?
Maybe I'm thinking about this wrong, but wouldn't this just change where the form is being submitted. The onSubmit event will only tell you the URL where the form is being submitted, but not the result after submission.
Am I missing a step here?