check for valid key string for javascript format

I am not sure if this is right