Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all, im using ASP.net, so im using code as below to do the validation group.
http://fiddle.jshell.net/N5BYk/2/[^]

now i need to enhance the validation by highlight the whole textbox and label if there is an error, see the image for sample.
http://oi58.tinypic.com/iv8v3b.jpg[^]

below is the code how i do that (not included inside the fiddle).
JavaScript
$("#form1").validate({
               highlight: function (element) {
                   $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
               },
               unhighlight: function (element) {
                   $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
               },
               errorElement: 'span',
               errorClass: 'help-block',
               onsubmit: false,
              errorPlacement: function (error, element) {
                   if (element.parent('.input-group').length) {
                       error.insertAfter(element.parent());
                   } else {
                       error.insertAfter(element);
                   }
               }
           });


i tried several ways, but still not success, anyone can advice me?
Posted
Comments
RelicV 11-Apr-14 5:55am    
melberry, can you provide your html code?.
melvintcs 11-Apr-14 21:41pm    
hi there, please check the fiddle :)
http://fiddle.jshell.net/N5BYk/2/
melvintcs 14-Apr-14 1:42am    
any idea? i still can't solve it ;(

1 solution

Hi melberry,

Sorry for the delay. Test this link CLICK HERE[^].

It highlights the textbox on click when there is no data in it.

Thank you,
RelicV
 
Share this answer
 
Comments
melvintcs 14-Apr-14 21:25pm    
Thx, it works great! possible the textbox border will change from red to green after the textbox passed the validation? the class for green is 'has-success'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900