• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation Class --> error message

#1
[eluser]hsl[/eluser]
Hello,

On this page I want to give the input fields that are not correct an
extra class (.red) instead of a whole message.

What is the best way to do this since the validation class doesn't give that option.

Thx,

hsl

#2
[eluser]Rey Philip Regis[/eluser]
Why do it manually? There are javascript libraries that can do the work for you like dojo. I know they have the feature you need.

http://dojotoolkit.org

Good day..

#3
[eluser]majidmx[/eluser]
Hey,
As Rey mentioned it's better to do it by Javascript.
But if you want to have both working exactly the same you can something like this :

Code:
<input type='text' value='<?PHP echo set_value('username'); ?>' class='<?PHP echo (isset(form_error('username') && form_error('username') != '')?'normal_css_class_name':'red_css_class_name'  ) ?>' />

I have not tried it yet, but it gives you the idea.

Take care,
MajiD Fatemian

#4
[eluser]hsl[/eluser]
Thx!

The javascript suggestion was one I didn't think of.

I'm implementing jquery right now. but i'm only going to use it for checking.

Smile

#5
[eluser]majidmx[/eluser]
Yeah, it's good to have Javascript validation all the time.
But always have the server-side equivalent too, just in case.
Passing the javascript validation is not that much hard Wink

Take care,
MajiD Fatemian


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.