Welcome Guest, Not a member yet? Register   Sign In
validation error
#1

[eluser]razerone[/eluser]
I have got a validation error.

I have got my validation working but instead of putting this <?php echo validation_errors(''); ?>

at top where it would show all errors

I would like to be able to just go like this

Code:
<form role="form" method="post" acti>
<div class="form-group">
&lt;input type="text" class="form-control" placeholder="Your Name" name="name"&gt;
&lt;?php echo validation_errors('name'); ?&gt;
</div>
<div class="form-group">
&lt;input type="text" class="form-control" placeholder="Your Email" name="email"&gt;
&lt;?php echo validation_errors('email'); ?&gt;
</div>
<div class="form-group">
&lt;input type="text" class="form-control" placeholder="Your Website Address" name="website"&gt;
&lt;?php echo validation_errors('website'); ?&gt;
</div>
<div class="form-group">
&lt;input type="text" class="form-control" placeholder="Your Subject" name="subject"&gt;
&lt;?php echo validation_errors('subject'); ?&gt;
</div>
<div class="form-group">
&lt;textarea class="form-control" rows="10" placeholder="Please Enter Your Message Min Text 15" name="message"&gt;&lt;/textarea>
&lt;?php echo validation_errors('message'); ?&gt;
</div>
<br>
<hr>
<div class="form-group">
<button type="reset" class="btn btn-danger">Clear Form</button>
<button type="submit" class="btn btn-success">Send Message</button>
</div>
&lt;/form&gt;

currently when press send four lines of error show up

http://www.development2.carrarawebsiteso.../contactus
#2

[eluser]Tpojka[/eluser]
What do errors say?
#3

[eluser]razerone[/eluser]
[quote author="Tpojka" date="1383213875"]What do errors say?[/quote]

I just got error fix before but as also in comment I would like to know if it is possible to get the input errors to show like this

Code:
&lt;input class="form-control" name="name" value="" placeholder=""&gt;

The Name field is required.

&lt;input class="form-control" name="name" value="" placeholder=""&gt;

The Email field is required.

And so on.

Currently just showing like this

Code:
&lt;input class="form-control" name="name" value="" placeholder=""&gt;

The Name field is required.

The Email field is required.

The Website field is required.

The Subject field is required.

The Message field is required.

&lt;input class="form-control" name="name" value="" placeholder=""&gt;

The Name field is required.

The Email field is required.

The Website field is required.

The Subject field is required.

The Message field is required.

You can try it out and see what I mean http://www.development2.carrarawebsiteso.../contactus
#4

[eluser]Tpojka[/eluser]
You are not doing something well.
Basic school example is working for me:

Code:
class Form extends CI_Controller {

function index()
{
  $this->load->helper(array('form', 'url'));

  $this->load->library('form_validation');

  $this->form_validation->set_rules('username', 'Username', 'required');
  $this->form_validation->set_rules('password', 'Password', 'required');
  $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
  $this->form_validation->set_rules('email', 'Email', 'required');

  if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('myform');
  }
  else
  {
   $this->load->view('formsuccess');
  }
}
}

Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php echo form_open('form'); ?&gt;

<h5>Username</h5>
&lt;?php echo form_error('username'); ?&gt;
&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" size="50" /&gt;

<h5>Password</h5>
&lt;?php echo form_error('password'); ?&gt;
&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?&gt;" size="50" /&gt;

<h5>Password Confirm</h5>
&lt;?php echo form_error('passconf'); ?&gt;
&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?&gt;" size="50" /&gt;

<h5>Email Address</h5>
&lt;?php echo form_error('email'); ?&gt;
&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<h3>Your form was successfully submitted!</h3>

<p>&lt;?php echo anchor('form', 'Try it again!'); ?&gt;</p>

&lt;/body&gt;
&lt;/html&gt;
#5

[eluser]razerone[/eluser]
[quote author="Tpojka" date="1383217903"]You are not doing something well.
Basic school example is working for me:

Code:
class Form extends CI_Controller {

function index()
{
  $this->load->helper(array('form', 'url'));

  $this->load->library('form_validation');

  $this->form_validation->set_rules('username', 'Username', 'required');
  $this->form_validation->set_rules('password', 'Password', 'required');
  $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
  $this->form_validation->set_rules('email', 'Email', 'required');

  if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('myform');
  }
  else
  {
   $this->load->view('formsuccess');
  }
}
}

Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php echo form_open('form'); ?&gt;

<h5>Username</h5>
&lt;?php echo form_error('username'); ?&gt;
&lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" size="50" /&gt;

<h5>Password</h5>
&lt;?php echo form_error('password'); ?&gt;
&lt;input type="text" name="password" value="&lt;?php echo set_value('password'); ?&gt;" size="50" /&gt;

<h5>Password Confirm</h5>
&lt;?php echo form_error('passconf'); ?&gt;
&lt;input type="text" name="passconf" value="&lt;?php echo set_value('passconf'); ?&gt;" size="50" /&gt;

<h5>Email Address</h5>
&lt;?php echo form_error('email'); ?&gt;
&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

<h3>Your form was successfully submitted!</h3>

<p>&lt;?php echo anchor('form', 'Try it again!'); ?&gt;</p>

&lt;/body&gt;
&lt;/html&gt;
[/quote]

Thanks will give it ago just slowly teaching my self going through userguide
#6

[eluser]Tpojka[/eluser]
User guide is best place to start with. Wink
#7

[eluser]razerone[/eluser]
[quote author="Tpojka" date="1383219296"]User guide is best place to start with. Wink[/quote]

Yes it is now found what I was after I must of missed that line

&lt;?php echo form_error('name', '<div class="alert alert-warning">', '</div>'); ?&gt;

much easier now thanks its hard when self teaching but have plenty of time on my side not allow to work until so getting my home business set up I was just going to learn html but switch to php can to more functions with php




Theme © iAndrew 2016 - Forum software by © MyBB