Welcome Guest, Not a member yet? Register   Sign In
help on this anyone?
#1

[eluser]mistress_shiira[/eluser]
Quote:<div style="font: 12px normal Verdana;color:red;">
&lt;?php
if($this->validation->error_string){
echo $this->validation->error_string;
echo "enable_button();";
}
?&gt;
</div>

hey guys can you help me with this?
i have a simple sign up form..when the user submits the form and there is still a validation error, i want the submit button to be enabled.the submit button was disabled on load fyi.

the code above doesnt seem to work...
#2

[eluser]xwero[/eluser]
Have you tried
Code:
if($this->validation->error_string != '')
#3

[eluser]mistress_shiira[/eluser]
[quote author="xwero" date="1193407333"]Have you tried
Code:
if($this->validation->error_string != '')
[/quote]

the code ive posted already checks for validation errors and echoes the validation error.
what i wanted is that when there is a validation error,the submit button should be enabled.
#4

[eluser]ballen[/eluser]
You could try something like

Code:
<div style="font: 12px normal Verdana;color:red;">
&lt;?php
$disabled = "disabled";
if($this->validation->error_string){
echo $this->validation->error_string;
$disabled = "";
}
?&gt;
</div>

and on your button

Code:
disabled = &lt;?php echo $disabled; ?&gt;
#5

[eluser]xwero[/eluser]
how do you disable it? I believe you used xajax but i'm not familiar with it.

I'm a jquery user and the way i do something like this is to change the class.
Code:
// view
&lt;input type="submit" class="&lt;?php echo $buttonclass; ?&gt;" value="send"&gt;
// js
$(function(){
   $('.enable:disabled').each(function(){
      this.disabled = false;
    });
  $('.disable:enabled').each(function(){
      this.disabled = true;
    });
});

I hope this can help you
#6

[eluser]mistress_shiira[/eluser]
Quote:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;Sign up Form&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="../system/application/css/calc.css" media="screen" /&gt;
&lt;?=form_open('Validate'); ?&gt;
&lt;?=$xajax_js?&gt;
&lt;/head&gt;
&lt;body onload="sign_up();"&gt;

&lt;!--
xajax.callback.global.onRequest=
function(){document.getElementById('loadingMessage').style.display='block';};
xajax.callback.global.onComplete = function(){
document.getElementById('loadingMessage').style.display='none';
};
function sign_up(){
xajax.$('submit').disabled=true;
}
function enable_button(){
xajax.$('submit').disabled = false;
}


// --&gt;
<div style="font: 12px normal Verdana;color:red;">
&lt;?php
if($this->validation->error_string){
echo $this->validation->error_string;
echo "enable_button();";
}
?&gt;
</div>
<div style="font: 12px normal Comic Sans;color:#000;">
<p><label for="username">Username:</label><br />
&lt;input type="text" id="username" name="username" tabindex="1" value="&lt;?=$this-&gt;validation->username;?&gt;" /></p>
&lt;input type="button" name="available" id="available" value="Check availability" tabindex="2" onclick="xajax_name_check(xajax.$('username').value);"/&gt;<br />
<p id="hello"></p>
<p><label for="password">Password:</label><br />
&lt;input type="password" id="password" name="password" value="&lt;?=$this-&gt;validation->password;?&gt;" tabindex="3" /></p>
<p><label for="email">Email Address:</label><br />
&lt;input type="text" id="email" name="email" value="&lt;?=$this-&gt;validation->email;?&gt;" tabindex="4" /></p>
<p><label for="country">Country</label><br />
&lt;input type="text" id="country" name="country" value="&lt;?=$this-&gt;validation->country;?&gt;" tabindex="5"/></p>
&lt;input type="submit" id="submit" name="submit" value="Submit" /&gt;
&lt;?=form_close();?&gt;
</div>
<div id="loadingMessage">
Processing your request...
<img src="../system/application/views/loader.gif" alt="" />
</div>
<div id="outputDiv">
</div>
im already posting the view file for this...
#7

[eluser]xwero[/eluser]
Seeing this code the function is not going to to be triggered because there is no trigger for it (oncomplete, onload).
You could try
Code:
echo "&lt;script&gt;enable_button();&lt;/script&gt;";

You should check the xajax documentation to see if you can attach the enable_button function to the oncomplete event that is how it works in jquery.
#8

[eluser]mistress_shiira[/eluser]
[quote author="xwero" date="1193417083"]Seeing this code the function is not going to to be triggered because there is no trigger for it (oncomplete, onload).
You could try
Code:
echo "&lt;script&gt;enable_button();&lt;/script&gt;";

You should check the xajax documentation to see if you can attach the enable_button function to the oncomplete event that is how it works in jquery.[/quote]

ive tried that though but it seems its not working..but thanks for the help.ill try to look it up on xajax implementation.thanks a lot xwero.
#9

[eluser]xwero[/eluser]
I don't know if you would consider this but instead of enable/disable the button why don't you hide/show the button? This can be done using only php.
#10

[eluser]Pygon[/eluser]
should work with:
Code:
echo "&lt;script type=\"text/javascript\"&gt;enable_button()&lt;/script&gt;"




Theme © iAndrew 2016 - Forum software by © MyBB