This topic is locked
[SOLVED]

 How To Remove Spaces At The End Of Each Form Field?

7/11/2013 11:35:49 AM
PHPRunner General questions
M
mik 62 author

hello

I need to know how to remove spaces at the end of each form field?
thanks

Sergey Kornilov admin 7/11/2013

What sort of spaces do you mean?

M
mik 62 author 7/11/2013

Sergey

i have a db in sql server fields with char ()

Sergey Kornilov admin 7/11/2013

Change it to VARCHAR?

M
mik 62 author 7/11/2013



Change it to VARCHAR?


Sergey

is not possible because the DB is composed of many tables, in each table there are many fields.

thanks

Sergey Kornilov admin 7/11/2013

The problem with CHAR fields is that they will be padded with spaces automatically every time you save your data. You cannot get rid of those spaces while you use CHAR fields.

M
mik 62 author 7/11/2013

Sergey

would be enough to remove the spaces in the focus of the field
// gotFOCUS

$(':input').focus(

function(){

$(this).css({'background-color' : '#FAFAD2'});

});

// lostFOCUS

$(':input').blur(

function(){

$(this).css({'background-color' : '#FFFFFF'});

});

M
mik 62 author 7/15/2013

Sergey

I solved in this way

the function under color also the field that has focus
// FOCUS ON FIELD

$(':input').focus(

function(){
// TRIM FIELD

var valoreCC = $.trim($(this).val() ) ;

this.value = valoreCC ;
// COLOR OF FIELD

$(this).css({'background-color' : '#FAFAD2'});

});
// OFF THE FIELD

$(':input').blur(

function(){

$(this).css({'background-color' : '#FFFFFF'});

});