Welcome Guest, Not a member yet? Register   Sign In
automatically goes to controller file.
#1

[eluser]Unknown[/eluser]
I tried javascript on my view file for client side validation to compare the password entered in two text boxes. Please see to the code below.

Code:
function pwdCompare() {
var p1 = document.profile.jpr_new_pass1.value;
p1 = p1.replace(/^\s+/g, "");  // strip leading spaces
var p2 = document.profile.jpr_new_pass2.value;
p2 = p2.replace(/^\s+/g, "");  // strip leading spaces
var rec = document.profile.hidf.value;
if ((p1.length < 6) || (p1 != p2)) {  // minimum 6 characters
alert ("The two passwords do not match or have too few characters!  Try again!");
document.profile.jpr_new_pass1.value = "";
document.profile.jpr_new_pass2.value = "";
document.profile.jpr_new_pass1.focus();
return false;
}
else
{
return true;
}
}



&lt;form action="profile" method="post" name="profile"&gt;
    <table width="100%" border="0" cellpadding="0">
    
        <tr>
            <td width="25%"><div align="right">Old Password </div></td>
            <td width="25%"><div align="center">
            &lt;input type="text" name="jpr_old_pass" id="jpr_old_pass"&gt;
            </div></td>
            <td width=50%></td>
            
        </tr>
        <tr>
            <td width="25%"><div align="right">New Password </div></td>
            <td width="25%"><div align="center">
            &lt;input type="text" name="jpr_new_pass1" id="jpr_new_pass1"&gt;
            </div></td>
            <td width=50%></td>
        </tr>
        <tr>
            <td width="25%"><div align="right">Confirm New Password </div></td>
            <td width="25%"><div align="center">
            &lt;input type="text" name="jpr_new_pass2" id="jpr_new_pass2"&gt;
            </div></td>
            <td width=50%></td>
        </tr>        
        <tr>
            <td colspan=2><div align="center">
            &lt;input type="submit" name="jpr_submit"
            id="jpr_submit" value="Edit"&gt;
            </td>
        </tr>
    </table>
&lt;/form&gt;

In the Controller file I called the view file as follows
Code:
$this->load->view('profile');
if(($this->input->post('jpr_submit'))
{

//Some code here

}
{

The issue is,in View file the client side validation is working perfectly and displays the error in alert box. When the user clicks on the "ok" in alert box. The textbox gets focused and loads automatically to controller file and runs the code on that file. But, I want only after the user enters the right value, the code on the controller side should run.

where I have went wrong? and how can i fix it? am a beginner, so please someone help me...




Theme © iAndrew 2016 - Forum software by © MyBB