javascript - Adding other functions between Jquery calls -


my first post. learning go along project, bare me!

below find code program. basically, have jquery calls fades in , out divs. however, before jquery fades out , fades in div, i'd check form validation , user input.

my question is, how add other functions in between jquery, have done validateform(); & validatepostalcode(); ?

jquery

<script type="text/jquery>     $(document).ready(function() {         $("#welcome").fadein('fast');          $('#forward').click(function(e) {             $('#welcome').fadeout('fast', function() {                 $('#service').fadein('fast');             });         });          $('#previous-service').click(function(e) {             $('#service').fadeout('fast', function() {                 $('#welcome').fadein('fast');             });         });          $('#next-service').click(function(e) {             postalcode();             validatepostalcode(true);             $('#service').fadeout('fast', function() {                 $('#match').fadein('fast');             });         });          $('#previous-match').click(function(e) {             $('#match').fadeout('fast', function() {                 $('#service').fadein('fast');             });         });          $('#next-match').click(function(e) {             $('#match').fadeout('fast', function() {                 $('#information').fadein('fast');             });         });          $('#previous-information').click(function(e) {             $('#information').fadeout('fast', function() {                 $('#match').fadein('fast');             });         });          $('#next-information').click(function(e) {             validateform();             $('#information').fadeout('fast', function() {                 $('#confirmation').fadein('fast');             });         }); 


javascript

<script type="text/javascript">     function validateform() {         var x = document.forms["#information"]["#first_name"].value;         if (x == null || x == "") {             alert("first name must filled out");             return false;         }     }      function validatepostalcode() {         var x = document.forms["#serviceform"]["#postal"].value;         if (x == null || x == "") {             alert("oops, postal code must filled out!");             return false;         }     } </script>  <script type="text/javascript">     function postalcode() {         var text = document.getelementbyid('postal').value;     } </script> 

html

<form id="informationform" action="" onsubmit="return validateform()" method="">     <div class="form-group">         <label for="first_name">first name</label>         <input type="text" class="form-control" id="first_name" autofocus required>     </div> 

jquery javascript.

you can add javascript between <script></script> tags.

example:

<script>   function normaljavascript(){      alert("hello js");      }    $(function(){     alert("i jquery on page ready function");     normaljavascript();   } </script> 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -