title: Jquery Modal/Dialog form not working
body: <p>Hi i'm new to coding &amp; trying to use the Jquery library Dialog/Modal form. I have all my CSS, JS and HTML in place but when i click on the "Create new user" the dialog/modal does not appear (the function behind the button does not work). I get the below error in the console - Any help would be much appreciated:</p>
  
  <p>error message in console:</p>
  
  <pre><code>Uncaught TypeError: undefined is not a function    main.js
  and it points to this ---&gt; dialog = $( "#dialog-form" ).dialog({
  </code></pre>
  
  <p>main.js file</p>
  
  <pre><code>$(function() {
      var dialog, form,
  
      // From http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29
      emailRegex = /^[a-zA-Z0-9.!#$%&amp;'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
      name = $( "#name" ),
      email = $( "#email" ),
      password = $( "#password" ),
      allFields = $( [] ).add( name ).add( email ).add( password ),
      tips = $( ".validateTips" );
  
    function updateTips( t ) {
      tips
        .text( t )
        .addClass( "ui-state-highlight" );
      setTimeout(function() {
        tips.removeClass( "ui-state-highlight", 1500 );
      }, 500 );
    }
  
    function checkLength( o, n, min, max ) {
      if ( o.val().length &gt; max || o.val().length &lt; min ) {
        o.addClass( "ui-state-error" );
        updateTips( "Length of " + n + " must be between " +
          min + " and " + max + "." );
        return false;
      } else {
        return true;
      }
    }
  
    function checkRegexp( o, regexp, n ) {
      if ( !( regexp.test( o.val() ) ) ) {
        o.addClass( "ui-state-error" );
        updateTips( n );
        return false;
      } else {
        return true;
      }
    }
  
    function addUser() {
      var valid = true;
      allFields.removeClass( "ui-state-error" );
  
      valid = valid &amp;&amp; checkLength( name, "username", 3, 16 );
      valid = valid &amp;&amp; checkLength( email, "email", 6, 80 );
      valid = valid &amp;&amp; checkLength( password, "password", 5, 16 );
  
      valid = valid &amp;&amp; checkRegexp( name, /^[a-z]([0-9a-z_\s])+$/i, "Username may consist of a-z, 0-9, underscores, spaces and must begin with a letter." );
      valid = valid &amp;&amp; checkRegexp( email, emailRegex, "eg. ui@jquery.com" );
      valid = valid &amp;&amp; checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );
  
      if ( valid ) {
        $( "#users tbody" ).append( "&lt;tr&gt;" +
          "&lt;td&gt;" + name.val() + "&lt;/td&gt;" +
          "&lt;td&gt;" + email.val() + "&lt;/td&gt;" +
          "&lt;td&gt;" + password.val() + "&lt;/td&gt;" +
        "&lt;/tr&gt;" );
        dialog.dialog( "close" );
      }
      return valid;
    }
  
    dialog = $( "#dialog-form" ).dialog({
      autoOpen: false,
      height: 300,
      width: 350,
      modal: true,
      buttons: {
        "Create an account": addUser,
        Cancel: function() {
          dialog.dialog( "close" );
        }
      },
      close: function() {
        form[ 0 ].reset();
        allFields.removeClass( "ui-state-error" );
      }
    });
  
    form = dialog.find( "form" ).on( "submit", function( event ) {
      event.preventDefault();
      addUser();
    });
  
    $( "#create-user" ).button().on( "click", function() {
      dialog.dialog( "open" );
    });
  });
  </code></pre>
  
  <p>index.html file</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Modal form&lt;/title&gt;
    &lt;link rel="stylesheet" type="text/css" media="all" href="css/reset.css" /&gt;
    &lt;link rel="stylesheet" type="text/css" media="all" href="css/grid.css" /&gt;  
    &lt;link rel="stylesheet" type="text/css" media="all" href="css/style.css" /&gt; 
    &lt;link href='http://fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'&gt;
    &lt;script src="js/jquery-1.11.2.js"&gt;&lt;/script&gt;
    &lt;script src="js/main.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
    &lt;div id="dialog-form" title="Create new user"&gt;
      &lt;p class="validateTips"&gt;All form fields are required.&lt;/p&gt;
      &lt;form&gt;
        &lt;fieldset&gt;
          &lt;label for="name"&gt;Name&lt;/label&gt;
          &lt;input type="text" name="name" id="name" value="Jane Smith" class="text ui-widget-content ui-corner-all"&gt;
          &lt;label for="email"&gt;Email&lt;/label&gt;
          &lt;input type="text" name="email" id="email" value="jane@smith.com" class="text ui-widget-content ui-corner-all"&gt;
          &lt;label for="password"&gt;Password&lt;/label&gt;
          &lt;input type="password" name="password" id="password" value="xxxxxxx" class="text ui-widget-content ui-corner-all"&gt;
          &lt;!-- Allow form submission with keyboard without duplicating the dialog button --&gt;
          &lt;input type="submit" tabindex="-1" style="position:absolute; top:-1000px"&gt;
        &lt;/fieldset&gt;
      &lt;/form&gt;
    &lt;/div&gt;
  
    &lt;div id="users-contain" class="ui-widget"&gt;
      &lt;h1&gt;Existing Users:&lt;/h1&gt;
      &lt;table id="users" class="ui-widget ui-widget-content"&gt;
        &lt;thead&gt;
          &lt;tr class="ui-widget-header "&gt;
            &lt;th&gt;Name&lt;/th&gt;
            &lt;th&gt;Email&lt;/th&gt;
            &lt;th&gt;Password&lt;/th&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
          &lt;tr&gt;
            &lt;td&gt;John Doe&lt;/td&gt;
            &lt;td&gt;john.doe@example.com&lt;/td&gt;
            &lt;td&gt;johndoe1&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
    &lt;button id="create-user"&gt;Create new user&lt;/button&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>