Monday, 15 June 2015

html - Javascript Prompt() Input validation -


I am struggling with HTML code to validate the input of JavaScript prompt () in an external JS file. I agree to call the Javascript function and I know how to write the function, but how do you "listen" to the quick and subsequent input of HTML?

What is prompting in HTML as a form of doctor?

Sorry, I can not wait ... here is the code I mentioned above in my comment Mentioned. JsFiddle

This is a completely working, stand alone example. Simply copy / paste and run in one file.

Note that the code needs to be referenced / loaded before loading jQuery and jQueryUI libraries themselves.

Honestly, prompt () these days is a bad idea for websites, maybe it's more that you want to do. Validation (which is typed in user) is done in the close section of the dialog.

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "// ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> & Lt; Script src = "// ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> & Lt; Link rel = "stylesheet" href = "http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /> & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ('# mybutt'). Click (function () {$ ('# msg'). Dialog ({autoOpen: true, modal: true, title: 'this one ('Off');}}, close: function () {var s = $ ('# sumpin'). Val (); if (S.length & lt; 15) warning ('Please exceed 15 characters Type '); Other alerts (' You typed: '+ s);}});});}); // END $ (document) .ready () & lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "msg" style = "display: none" & gt; Write something here: & lt; Br / & gt; & Lt; Input id = "sumpin" type = "text" & gt; & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Input type = "button" id = "mybutt" value = "click me" & gt; & Lt; / Body & gt; & Lt; / Html & gt;    

No comments:

Post a Comment