karan k
karan k

Reputation: 977

Is it possible to type a macron inside a HTML textbox?

I'm validating a HTML textbox field<input type="text" />, and I need to detect if the user has entered a Macron in the textbox. My question is that is there any way to TYPE (Not copy-paste) a Macron into an HTML textbox?? If so, how would you detect if the user has typed a Macron?

I've checked this page. At the bottom, it's shown how to type it, but I couldn't.

Upvotes: 0

Views: 1127

Answers (2)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201748

Yes, you should always assume that users can type any character in a textbox. This is true no matter what you mean by “macron” here. It could mean U+00AF MACRON “¯”, or U+0304 COMBINING MACRON, or macron as part of a character as in U+0101 LATIN SMALL LETTER A WITH MACRON “ā”.

For example, using a normal Finnish keyboard with a keyboard driver that conforms to the modern Finnish standard, I typed “¯” using just AltGr ¨ space and “ā” using AltGr ¨ A. Entering the combining macron is possible using e.g. my own keyboard driver for combining marks or the “universal method” described on the Fileformat.info page How to enter Unicode characters in Microsoft Windows.

You can detect a macron, in any meaning, by inspecting the value of the field. When using JavaScript, you can e.g. check whether the value contains \u00af (if you are not sure how to enter “¯” directly into your code and ensure that it is reas properly).

Upvotes: 0

Marcel
Marcel

Reputation: 1514

Yes it is possible with Alt Codes

Alt-0175 Gives a macron ¯ in a input field.

However, i dont know how to combite the macron with a character, but that wasn't the question.

EDIT : found these ALT codes for macron characters. (only work in Word)

Lowercase Vowels

  • ā ALT+0257 Lower long A
  • ē ALT+0275 Lower long E
  • ī ALT+0299 Lower long I
  • ō ALT+0333 Lower long O
  • ū ALT+0363 Lower long U
  • ȳ ALT+0562 Lower long Y
  • æ ALT+0230 Lower AE lig
  • œ ALT+0156 Lower OE lig

Capital Vowels

  • Ā ALT+0256 Cap long A
  • Ē ALT+0274 Cap long E
  • Ī ALT+0298 Cap long I
  • Ō ALT+0332 Cap long O
  • Ū ALT+0362 Cap long U
  • Ȳ ALT+0563 Cap long Y
  • Æ ALT+0198 Cap AE lig
  • Œ ALT+0140 Cap OE lig

Upvotes: 1

Related Questions