I will give a nephew and I will suggest a solution with jQuery plugin:
link
In the examples block, take a look at the "translate" functionality. Adapting to the rules of longitude would look something like this:
$('input.longitude').mask('99Z.99999999', {
translation: {
'Z': {
pattern: /[0-9]/,
optional: true
}
}
});
In this way, if the user enters two digits and then the point, the mask will not move the place point. But it is mandatory for the user to enter the period.
The number of decimal places is at the discretion of the project - Google Maps uses 8 houses after the comma, but if I am not mistaken, the longitude pattern can be up to 13 digits after the point.