how can I not processing the form If not all required fields have been filled in?
Hello,
I have a form and I validate the form. This is required: at least one letter, at least one capital letter, at least one number, be at least 8 characters.
I want to have if all is required is done then processing the form.
But now if you type one letter and you click on the button then is the form processing.
my question is: how can I not processing the form If not all required fields have been filled in?
thanks in advance.
the code is:
- $(document).ready(function(e) {
- $('input[type=password]').keyup(function(e) {
-
- // if(pswd == false)
- //{
- // stopEvent(e);
- // }
-
- var pswd = $(this).val();
-
- //validate the length
- if ( pswd.length < 8 ) {
- $('#length').removeClass('valid').addClass('invalid');
- //return false;
-
- } else {
- $('#length').removeClass('invalid').addClass('valid');
- // return true;
- }
- //validate letter
- if ( pswd.match(/[A-z]/) ) {
- $('#letter').removeClass('invalid').addClass('valid');
- } else {
- $('#letter').removeClass('valid').addClass('invalid');
-
- }
- //validate capital letter
- if ( pswd.match(/[A-Z]/) ) {
- $('#capital').removeClass('invalid').addClass('valid');
- } else {
- $('#capital').removeClass('valid').addClass('invalid');
-
- }
- //validate number
- if ( pswd.match(/\d/) ) {
- $('#number').removeClass('invalid').addClass('valid');
- } else {
- $('#number').removeClass('valid').addClass('invalid');
-
- }
-
- // keyup code here
- }).focus(function() {
- $('#pswd_info').show();
- }).blur(function() {
- $('#pswd_info').hide();
- });
- //function stopEvent(e) {
- if (e.stopPropagation) e.stopPropagation();
- else e.cancelBubble = true;
- if (e.preventDefault) e.preventDefault();
- else e.returnValue = false;
- //}
- });