In your case you should use javascript. You can handle blur
event of your input and check if it's empty or not. If it's not add some additional class which change width to 500px;
You can see working (jQuery) example here
Also :visited
pseudo-class works only for links.