HTML and CSS Reference
In-Depth Information
//Check if the user has entered anything
if ( film == '' ){
//If the input field was empty, display a message
$ ( '#poster' ). html ( "<h2 class='loading'>Ha! We haven't forgotten to
validate the form! Please enter something.</h2>" );
The reason why we store the main code that retrieves the data in a function will become clear
later on (mainly, it's for DRY programming ).
We then store the value of the input in a variable, so that when we use it again in the code, the
jQuery doesn't have to rescan the DOM.
Basic validation is performed on the input, checking that something has actually been entered
in the field.
In an attempt at humor on my part, I display a message warning the user that they haven't
entered anything and asking them to please do so.
Search WWH ::

Custom Search