I posted this yesterday, but didn't see my original in my email, so didn't
know if

it never made it, or if it was perhaps just not answered.but I thought I'd
post it

again so if anyone has any ideas.

 

Rick

 

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

 

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
to

address handling the error messages and user text input:            

 

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.

 

Is it the order or structure of the code that's the problem?

 

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