F#
HTML
Result
Hosted on
Try WebSharper
<
>
namespace LoginWithWebSharperForms open WebSharper open WebSharper.UI open WebSharper.UI.Html [<JavaScript>] module Client = open WebSharper.JavaScript open WebSharper.UI.Client open WebSharper.Forms open WebSharper.Forms.Bootstrap let loginForm = Form.Return (fun user pass check -> user, pass, check) <*> (Form.Yield "" |> Validation.IsNotEmpty "Must enter a username") <*> (Form.Yield "" |> Validation.IsNotEmpty "Must enter a password") <*> Form.Yield false |> Form.WithSubmit |> Form.Run (fun (user, pass, check) -> JS.Alert("Welcome, " + user + "!") ) |> Form.Render (fun user pass check submit -> form [] [ Controls.Simple.InputWithError "Username" user submit.View Controls.Simple.InputPasswordWithError "Password" pass submit.View Controls.Simple.Checkbox "Keep me logged in" check Controls.Button "Log in" [attr.``class`` "btn btn-primary"] submit.Trigger Controls.ShowErrors [attr.style "margin-top:1em;"] submit.View ] ) |> fun s -> s.RunById "main"
<html> <head> <title></title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous"> </head> <body> <div id="main"></div> <!--[BODY]--> </body> </html>