Can anyone spot why my form always fails the validation?
The validation doesn’t output any errors, and the POST array is always empty.
Suggests to me, its getting submitted to the wrong place but thats not the case.
<form action="https://www.mydomain.com/account/withdraw" method="post" accept-charset="utf-8"> <fieldset class="six-col">
<h3>What amount?</h3>
<span style="font-size:1.3em;position:relative;display:inline;">£</span>
<input id="amount" type="text" placeholder="1.00" style="font-size:1.3em;width:115px;background-color: transparent;color:white;"/>
</fieldset>
<fieldset class="six-col">
<h3>Charges</h3>
<span id="charges" style="font-size:1.3em;"></span>
</fieldset>
<fieldset class="six-col">
<h3>You leave with</h3>
<span id="charges2" style="font-size:1.3em;"></span>
</fieldset>
<fieldset class="six-col end-col">
<input type="submit" id="submit" class="btn" value="Withdraw" style="width:125px;position:absolute;bottom:0" />
</fieldset>
</form>
Here is the controller
$this->load->library('form_validation');
$this->form_validation->set_rules('amount', 'Amount', 'required|xss_clean|trim|numeric|max_length[5]');
if ($this->form_validation->run() == FALSE)
{
$this->load->helper(array('form', 'url'));
$data['credit'] = $this->account_m->get_credit();
$this->load->view('account/withdraw', $data);
}
else
{
// The withdraw code
}
$this->load->view('footer');
Thanks for any help
You don’t have name set in the input..
it should be:
<input name="amount" id="amount" type="text" placeholder="1.00" style="font-size:1.3em;width:115px;background-color: transparent;color:white;"/>Make sure you’re actually getting something back.
If at all possible to test.. echo the post var before the form_validation like so:
If you aren’t getting a value back then its the form, try using
POSTinstead ofpost.If you are getting a value back then its the rule. One possibility is the
numericrule, try integer. Tryis_naturalor trydecimalif you’re using $0.00.Also, use codeigniter’s profiler class for development..
http://codeigniter.com/user_guide/general/profiling.html