javascript - Implement jQuery in separated file with html -


is 2 hours im trying understand how use jquery file html, can't figure out! want simple strngh password using jquery , found useful link: http://jsfiddle.net/jquery4u/mmxv5/ problem how allow file html communicate script? file html simple:

<form name="register" id="signup" method="post" onsubmit="return validateform()" action="register_user.php">         <div class="header">             <h3>registration</h3>             <p>complete form register.<br/>* required field</p>         </div>          <div class="sep"></div>          <div class="inputs">             <input type="text" placeholder="name" name="name" autofocus />*             <input type="text" placeholder="surname" name="surname" autofocus />*             <input type="text" placeholder="email" name="email" autofocus />*             <input type="password" placeholder="password" name="password" />*              <div class="sep"></div>             <div id="messages"></div>             <input type="submit" id="submit" name="submit" value="confirm registration">                         </div>     </form> 

as see, javascript file of link consistent want put codes file, after don't know how link 2 file , work togheter!

here useful link learn more jquery.

you need add file (in head or right before closing body tag).

<script>src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> allows use jquery library. after include ajax library google (this preferable added inside <head> *insert here </head> tags.

now, if have external js file, add jquery code , import in html file. <script src="yourfilewithjquery.js"></script>. note js file has in same folder html file.

now go.

here example on code:

<head>     <script> src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>     <script src="myjsfile.js"></script> </head> <body> <form name="register" id="signup" method="post" onsubmit="return validateform()" action="register_user.php">                 <div class="header">                     <h3>registration</h3>                     <p>complete form register.<br/>* required field</p>                 </div>                  <div class="sep"></div>                  <div class="inputs">                     <input type="text" placeholder="name" name="name" autofocus />*                     <input type="text" placeholder="surname" name="surname" autofocus />*                     <input type="text" placeholder="email" name="email" autofocus />*                     <input type="password" placeholder="password" name="password" />*                      <div class="sep"></div>                     <div id="messages"></div>                     <input type="submit" id="submit" name="submit" value="confirm registration">                                 </div>     </form> </body> 

Comments