numkeyOpen source by DevsLab

numkey

It's a string, but it's a number. Numeric input formatting, done once.
λ¬Έμžμ—΄μΈλ° 숫자인 ν•„λ“œ. μ½€λ§ˆΒ·μ»€μ„œΒ·μ •λ ¬Β·μ•žμžλ¦¬ 0, ν•œ λ²ˆμ— 끝.

Try it β€” everything below is just markup / μ „λΆ€ λ§ˆν¬μ—…λ§ŒμœΌλ‘œ λ™μž‘ν•©λ‹ˆλ‹€

canonical:

Korean amount reading / ν•œκΈ€ κΈˆμ•‘ 병기 β€” 은행 UI의 "150만"을 λ§ˆν¬μ—…λ§ŒμœΌλ‘œ

The generated <span class="numkey-korean"> is unstyled β€” the "원" here comes from CSS ::after. Also a pure function: toKorean('927483041001') β†’ 9,274μ–΅ 8,304만 1,001.

hangulλ§ν•˜λ“―μ΄ β€” μ•ˆλ‚΄ 문ꡬ
formalλͺ¨λ“  μžλ¦¬μ— 일 β€” κ³„μ•½μ„œΒ·μ˜μˆ˜μ¦
hanjaκ°–μ€μž β€” μˆ˜ν‘œΒ·μ–΄μŒΒ·μž…κΈˆν‘œ

Markup-only: <input data-numkey data-numkey-korean data-numkey-korean-style="formal">. The "금 … 원정" frame around the number is yours to add β€” it differs per document.

A Korean draft is left alone while typing (no fight with the IME); blur converts it β€” 3만5천 β†’ 35,000. The reading and any data-numkey-name hidden field see the parsed value even mid-draft.

Form POST, solved / 폼 전솑은 hidden이 정식 κ°’μœΌλ‘œ β€” μ„œλ²„ 콀마 제거 λΆˆν•„μš”

the hidden input will POST:

Locale (opt-in) / λ‘œμΌ€μΌμ€ 옡트인 β€” 기본값은 λΈŒλΌμš°μ €μ™€ λ¬΄κ΄€ν•˜κ²Œ κ³ μ •

data-numkey is the on-switch; data-numkey-locale is an option on top of it that only changes how the value is drawn. The canonical value stays the same.
data-numkeyκ°€ μŠ€μœ„μΉ˜, data-numkey-locale은 κ·Έ μœ„μ˜ ν‘œμ‹œ μ˜΅μ…˜ β€” 정식 값은 κ·ΈλŒ€λ‘œμž…λ‹ˆλ‹€.

<input data-numkey="2">                          <!-- everyone: 1,234,567.89 -->
<input data-numkey="2" data-numkey-locale="auto">  <!-- browser language:
                                                        de β†’ 1.234.567,89
                                                        ko β†’ 1,234,567.89 -->
<input data-numkey="2" data-numkey-locale="de-DE"> <!-- pinned German -->
<input data-numkey-locale="auto">                  <!-- βœ— nothing: no data-numkey -->
canonical stays:

No build step / JSPΒ·PHP·정적 νŽ˜μ΄μ§€ β€” 슀크립트 νƒœκ·Έ ν•œ 쀄

<script src="https://cdn.jsdelivr.net/npm/@devslab/numkey"></script>

<input data-numkey>                       <!-- 1,234,567 -->
<input data-numkey="2">                   <!-- 1,234.56 -->
<input data-numkey data-numkey-negative>  <!-- minus ok -->

Vue 3 / React adapters and the full API: README. Wrong-keyboard-layout text in the same form? See numkey's sibling kokey.