Skip to content

Instantly share code, notes, and snippets.

@shamrin
Last active June 19, 2016 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shamrin/f29672717fc0df775486a7ece0650412 to your computer and use it in GitHub Desktop.
Save shamrin/f29672717fc0df775486a7ece0650412 to your computer and use it in GitHub Desktop.
import Html exposing (Html, Attribute, text, div, input)
import Html.App exposing (beginnerProgram)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, on)
import String
main =
beginnerProgram { model = "", view = view, update = update }
-- UPDATE
type Msg
= NewContent String
| NoOp
update msg oldContent =
case msg of
NewContent content ->
content
NoOp ->
oldContent
-- VIEW
view content =
input [ type' "number", onInput handleInput, value content ] []
handleInput : String -> Msg
handleInput s =
if String.length s <= 2 then NewContent s else NoOp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment