jquery - Javascript Not Running or Working? -


i have project includes login form password meter. followed a tutorial cssdeck, tried copy-pasting code jsfiddle see results. works on demo, not on my jsfiddle. issue password meter not working. have read through javascript , can not see wrong it.
suggestions nice. why exact same code not work in fiddle?

$(function(){     var pass1 = $('#password1'),         pass2 = $('#password2'),         email = $('#email'),         form = $('#main form'),         arrow = $('#main .arrow');      // empty fields on load     $('#main .row input').val('');      // handle form submissions     form.on('submit', function(e){         // entered correctly?         if ($('#main .row.success').length == $('#main .row').length) {             // yes!             alert("thank trying out demo!");             e.preventdefault();             // remove allow actual submission         } else {             // no. prevent form submission             e.preventdefault();         }     });      // validate email field     email.on('blur', function(){         // simple validation         if (!/^\s+@\s+\.\s+$/.test(email.val())) {             email.parent().addclass('error').removeclass('success');         } else {             email.parent().removeclass('error').addclass('success');         }     });      // use complexify plugin on first password field     pass1.complexify({minimumchars: 6, strengthscalefactor: 0.7},         function(valid, complexity){             if (valid) {                 pass2.removeattr('disabled');                 pass1.parent().removeclass('error').addclass('success');             } else {                 pass2.attr('disabled','true');                 pass1.parent().removeclass('success').addclass('error');             }              var calculated = (complexity / 100) * 268 - 134;             var prop = 'rotate(' + (calculated) + 'deg)';             // rotate arrow             arrow.css({                 '-moz-transform': prop,                 '-webkit-transform': prop,                 '-o-transform': prop,                 '-ms-transform': prop,                 'transform': prop             });         }     );      // validate second password field     pass2.on('keydown input', function(){         // make sure value equals first's         if (pass2.val() == pass1.val()) {             pass2.parent().removeclass('error').addclass('success');         } else {             pass2.parent().removeclass('success').addclass('error');         }     }); }); 

the jquery.complexify plugin included well.

you haven't included jquery library in code.

this fiddle enter image description here

you need include jquery in fiddle enter image description here

this fiddle of same code after adding jquery https://jsfiddle.net/5n90vlgn/

in page need include before writing js code or including external js file, include jquery cdn (*), i.e

<script src="//code.jquery.com/jquery-1.12.0.min.js"></script> 

or include local copy of jquery like:

<script src="path/to/jquery.js/"></script> 

(*) above cdn jquery website, there other cdn of jquery though google libraries or cdnjs libraries


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -