In code prior to this, if an empty text input is found in a form upon
submission,

the text "Entry required." is put into the text input.

 

Once all the text inputs have been validated, then the function below is
run:            

 

function validation() {

                     

     $(':input.inputError').each(function() {

                                         

          $(this).focus(function() {

               $(this).val('');

                                                

          });

     });

                                  

     $(':input.inputError').each(function() {

                                         

          $(this).blur(function() {

                                                

               if   (   $(this).val().length > 0            )

                    {
$(this).removeClass('inputError').css({'background-color':'#ddd' ,
'color':'#000'});    }

                                                       

               if   (   $(this).val().length == 0           )

                    {   $(this).val('Entry required...');   }

                                                       

          });

     });

}

 

It all works well, except for the fact that once I do make an entry into an
invalid field,

and blur out of that field, then re-focus the cursor in that same field, my
valid data entry

is removed.

 

With the code above, I try to avoid that happening by removing the class,
"input error", which

is happening according to Firebug, so I'm not sure why the "val" is being
reset to '' or nothing

upon re-focus.

 

Thoughts?

 

Have I missed another fundamental javascript coding principle, MZ? ;o)

 

Rick

 

----------------------------------------------------------------------------
---------------------------------------

"Those who hammer their guns into plows will plow for those who do not."  -
Thomas Jefferson

 

Reply via email to