I was about to write up in detail how you could do it, but that would take 
away some learning from you so here are some ideas:

- Putting color in the model strikes me as a bad idea, that should be a 
view concern that should be possible to derive from the model
- Maybe you could try to define a type describing a validation result 
(maybe containing None, Error String and OK). Look at your Msg type for a 
little inspiration
- Have a validation function that takes the model as input and return a 
validation result (type) 
- Have a viewValidation function that based on the current value of 
validationResult in your model displays either an error with color or ok 
(or nothing in the case of not having validated anything yet).

give it a try, and if you are stuck we can go from there !

cheers
-magnus



On Wednesday, 25 May 2016 05:01:17 UTC+2, 大魔头 wrote:
>
> hi, 
>
> in http://guide.elm-lang.org/architecture/user_input/forms.html , there 
> is an exercise:
>
>    - Add a "Submit" button. Only show errors *after* it has been pressed.
>
> I tried and find it not as easy as I thought. I have to put color and 
> message in the model, I put the result code here: 
> https://gist.github.com/notyy/d2f9fb4087e26d42e450a956c51f054d
>
> it works, but...
> would anyone please help me review the code and give me some hints?
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to