Welcome Guest, Not a member yet? Register   Sign In
[Closed] Codeigniter Validation Question
#4

[eluser]riwakawd[/eluser]
[quote author="Tim Brownlaw" date="1399535438"]disclaimer: I'm only answering the question on the code provided.

Ok so you are testing that validation_errors() returns a boolean result...

So you need to understand what the function you are testing is going to return...
In this case It's either a string or empty... - I've NOT looked in the code to make sure... which is something you should do to make 100% sure it's the case!

You also need to check your PHP Syntax...

** I've not tested this code - it's a "it might work" suggestion to get you started...

Code:
<div class="form-group
&lt;?php
if(validation_errors() != '')
   echo 'has-error';
else
  echo 'has-success';
?&gt;
">
<label for="input-username">&lt;?php echo $entry_username;?&gt;</label>
&lt;input type="text" name="username" value="&lt;?php echo set_value('username');?&gt;" placeholder="&lt;?php echo $entry_username;?&gt;" id="input-username" class="form-control" /&gt;
</div>

What you have there is an interesting way to do things...
I've only broken the php code out to elaborate on the actual code used.

The other way to try is...

Code:
&lt;?php echo (validation_errors() != '')? 'has-error':'has-success'; ?&gt;


Cheers
Tim[/quote]

This works but is there also just away to make has-success show up only when start to type? I am trying to find a suitable javascript to match and work with codeigniter. Can Not seem to get javascript to work with codeigniter

Code:
&lt;?php echo (validation_errors() != '')? 'has-error':'has-success'; ?&gt;

Code:
[removed]
$(document).ready(function () {

    $('#register-form').validate({
        rules: {
            firstname: {
                minlength: 2,
                required: true
            },
            lastname: {
                minlength: 2,
                required: true
            },
            password: {
                minlength: 2,
                required: true
            },
            email: {
                required: true,
                email: true
            },
            username: {
                minlength: 2,
                required: true
            }
        },
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
        },
        success: function (element) {
            element.text('OK!').addClass('valid')
                .closest('.form-group').removeClass('has-error').addClass('has-success');
        }
    });

});
[removed]


Messages In This Thread
[Closed] Codeigniter Validation Question - by El Forum - 05-07-2014, 10:49 PM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 12:50 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 01:21 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 01:39 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 01:52 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 02:22 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 02:35 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 12:26 PM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 05:12 PM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 05:27 PM
[Closed] Codeigniter Validation Question - by El Forum - 05-08-2014, 11:56 PM
[Closed] Codeigniter Validation Question - by El Forum - 05-09-2014, 03:10 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-09-2014, 05:55 AM
[Closed] Codeigniter Validation Question - by El Forum - 05-10-2014, 01:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB