I'm seeing 2 issues.
The first is the behavior of Brown, S versus Brown,S
You can: 1. put both in the database (has clear usability issues), 2. put a function in your source: option to add a space in a "character comma character" substring (may have usability issues - how is Smith, Jr., John handled), or 3. do nothing and let your users figure out how to use the dropdown option list that you present.
The second issue is text being cleared from the input box. You didn't post any code, so its only speculation here, but I suspect a problem in your source: option. The code below does not clear the input box when strange inputs go in. Maybe it will help you. If not, come back with some code.
source: function (request, response){
$.ajax(
{
url: "yourServer.php",
type: "POST", // POST transmits (key=value&key1=value1) in utf-8
dataType: "json", //return data in json format
success: function (data)
{
response($.map( data, function (item)
{
return {
label: item.stateName,
value: item.name,
abbrev: item.stateAbbrev,
}
}));
}
});
},