Reset password validation not working

Have you tried using the “Analyze JavaScript” function on CodePen to see where the errors lie?

Looking at the example you ignored all the help. The script tags are back as well as the same errors that I fixed.

This is the codepen using your latest code. Put through prettier and standardJS. Again I have fixed a lot of the bugs.

Furthermore your code is strewn throughout with commented out blocks

e.g.

// .addClass("glyphicon glyphicon-remove warning");
      // $(this)
      // .next()
      //   .find(".error")
      // .removeClass("ok")
      //   .addClass("ok");

      // event.preventDefault();

and

// var $form = $("form.register");
  // var inputs = $form[0].elements;

  // alert(inputattr+inputstr);
  if (inputstr !== '') {

or

if ($(this).find('.input-check').val().trim() !== '') {
      // $($(this).nextAll(".inputstatus")).find(".fielderror").text("Your " + st + " is OK ");
      // $(this).find(".fielderror").text("Your " + st + " is OK ");
      $(this)

It’s a rat’s nest.

These are the error’s remaining.

1131:17 - ‘inputattr’ is not defined. (no-undef)
1214:11 - ‘namem’ is assigned a value but never used. (no-unused-vars)
1215:11 - ‘valuem’ is assigned a value but never used. (no-unused-vars)
1217:11 - ‘fakeRegm’ is assigned a value but never used. (no-unused-vars)
1218:11 - ‘emailRegm’ is assigned a value but never used. (no-unused-vars)
1219:11 - ‘pswReglowm’ is assigned a value but never used. (no-unused-vars)
1220:11 - ‘pswRegheighm’ is assigned a value but never used. (no-unused-vars)
1222:11 - ‘$formm’ is assigned a value but never used. (no-unused-vars)
1223:11 - ‘inputsm’ is assigned a value but never used. (no-unused-vars)
1223:21 - ‘$form’ is not defined. (no-undef)
1230:9 - ‘name’ is not defined. (no-undef)
1231:11 - ‘value’ is not defined. (no-undef)
1235:13 - ‘fakeReg’ is not defined. (no-undef)
1235:26 - ‘value’ is not defined. (no-undef)
1239:19 - ‘name’ is not defined. (no-undef)
1251:15 - ‘emailReg’ is not defined. (no-undef)
1251:29 - ‘value’ is not defined. (no-undef)
1255:21 - ‘name’ is not defined. (no-undef)
1270:21 - ‘name’ is not defined. (no-undef)
1287:17 - ‘name’ is not defined. (no-undef)
1302:9 - ‘name’ is not defined. (no-undef)
1305:11 - ‘value’ is not defined. (no-undef)
1315:13 - ‘fakeReg’ is not defined. (no-undef)
1315:26 - ‘value’ is not defined. (no-undef)
1319:19 - ‘name’ is not defined. (no-undef)
1332:15 - ‘value’ is not defined. (no-undef)
1332:25 - ‘inputs’ is not defined. (no-undef)
1336:21 - ‘name’ is not defined. (no-undef)
1348:17 - ‘value’ is not defined. (no-undef)
1348:27 - ‘inputs’ is not defined. (no-undef)
1353:19 - ‘name’ is not defined. (no-undef)
1371:19 - ‘value’ is not defined. (no-undef)
1371:29 - ‘inputs’ is not defined. (no-undef)
1376:21 - ‘name’ is not defined. (no-undef)
1393:37 - ‘value’ is not defined. (no-undef)
1398:23 - ‘name’ is not defined. (no-undef)
1415:41 - ‘value’ is not defined. (no-undef)
1422:25 - ‘name’ is not defined. (no-undef)
1443:25 - ‘name’ is not defined. (no-undef)
1445:27 - ‘inputstr’ is not defined. (no-undef)
1475:17 - ‘inputattr’ is not defined. (no-undef)
1484:9 - ‘name’ is not defined. (no-undef)
1485:7 - ‘alert’ is not defined. (no-undef)
1485:13 - ‘value’ is not defined. (no-undef)
1486:11 - ‘value’ is not defined. (no-undef)
1487:13 - ‘value’ is not defined. (no-undef)
1487:23 - ‘inputs’ is not defined. (no-undef)
1488:11 - ‘alert’ is not defined. (no-undef)
1488:17 - ‘name’ is not defined. (no-undef)
1492:19 - ‘name’ is not defined. (no-undef)
1508:15 - ‘name’ is not defined. (no-undef)
1508:72 - ‘inputstr’ is not defined. (no-undef)
1528:17 - ‘name’ is not defined. (no-undef)
1819:11 - ‘st2’ is assigned a value but never used. (no-unused-vars)
1873:11 - ‘st2’ is assigned a value but never used. (no-unused-vars)
1930:9 - ‘value’ is assigned a value but never used. (no-unused-vars)
2112:11 - ‘st2’ is assigned a value but never used. (no-unused-vars)
2152:7 - ‘event’ is not defined. (no-undef)
2162:11 - ‘st2’ is assigned a value but never used. (no-unused-vars)

Paul did give you the option to go down a much simpler and more manageable route. I think it is unfortunate you didn’t take him up on the offer.

1 Like

I am sorry I screwed up a number of times, thank you for help, I try to fix them.
also it is strange, I have only four error with w3 validator, I don’t understand it.

Error: CSS: Parse Error.

From line 119, column 35; to line 119, column 36

down-menu>li,↩    

Error: CSS: transform: Parse Error.

At line 244, column 13

 {↩			transform:;↩			-ms-trans

Error: CSS: Parse Error.

From line 1148, column 36; to line 1148, column 51

-control::-moz-placeholder {↩   

Error: CSS: Parse Error.

From line 1168, column 38; to line 1168, column 53

-control::-moz-placeholder {↩
1 Like

Just having another brief look (approx around line 1210), it appears you have added m’s to the end of your regexes e.g. fakeRegm, namem etc.

I guess that was intentional? Maybe in an error hunt and a process of elimination?

If you remove the ‘m’ from the variable names e.g.

const name = $(this).find('.check,textarea').attr('name')
const value = $(this).find('.check,textarea').val().trim()

const fakeReg = /(.)\1{2,}/
const emailReg = /^([\w-.]+@([\w-]+\.)+[\w-]{2,4})?$/
const pswReglow = /^([a-zA-Z0-9]{6,})+$/
const pswRegheigh = /^([a-zA-Z0-9]{13,})+$/ // 13 or more occurences

const modalForms = $('form.modalform')
const inputs = modalForms[0].elements

it reduces the error count down to 14

edit: Ok so one thing that did stand out to me was pswReglow and pswRegheigh

The password needs to be between 6 - 12 characters right?

Can’t you just check for that with the following

const passwordLength = /^[a-z0-9]{6,13}$/i

e.g.
incorrect: password must be between 6 and 12 characters long and contain letters or/and numbers’

Rather than going around the houses with separate blocks checking for ‘too few’, ‘just right’, ‘too many’

thank you for help. yes I try to separate modalform from registration form, that’s why added m to the variables end. at current state the code can confuse the browser. thank you, please help me.
also the registration form more or less works as I expect, if you check it you’ll see even the reset and submit button but the modal not really.

This is my new experiment, with problems. please check it out. the problem is the modal. it doesn’t submit the data. at first might submit , second time don’t, please help me, thank you.
experiment

I have unlisted your thread until you sort out your code. Other members have already corrected code for you, yet you have ignored all the help and advice given and are continuing to post code with known and obvious errors.

Of course nothing will work as expected if you don’t correct known errors.

Please fix all the errors you have already been shown how to fix, and if others remain which you don’t understand, then ask about those, one at a time.

I will relist your thread when you have corrected your code.

3 Likes

I am currently away all week, but when I return I’ll use the existing code to rewrite a much improved version of the code.

1 Like

thank you for help. that’s ok. I have problem with correcting errors, what w3 validator shows is a lot less and looks different from the list shown. also I am planning to add/change two things. can I post it? thank you.

As has been explained before, the W3C validators will show you errors in your HTML and CSS. The errors which have been noted above are errors in the JavaScript. You can use the “Analyse JavaScript” facility on CodePen to look at those.

thank you for help. I need help with ‘merging’ two scripts to get the form in working condition, I commented out and relevant paers. thank you.

                                        
                $(".form-group").each(function() {
                        var $requiredField = $(this).find(".check,check2");
                            if ($requiredField.length === 0) {
                                return;
                            }
                        if ( $(".inputstatus .warning").length != 0) {
                            event.preventDefault();
                        }   
                            var name = $requiredField.attr("name");
                            var value = $requiredField.val().trim();
                         if (value == "") {
                            $(this).find(".error").html(name).removeClass("warning").addClass("ok");
                            $(this).find(".feedback").removeClass("glyphicon glyphicon-ok").removeClass("glyphicon glyphicon-remove").removeClass("warning");
                            $(this).find(".starrq").removeClass("warning").addClass("ok");
						    $("#termcheck").removeClass('ok').addClass('warning');
				            $("#termsRequired").removeClass('ok').addClass('warning');
                        } else {
							$(this).find(".error").html(name).removeClass("warning").addClass("ok");
                            $(this).find(".feedback").removeClass("glyphicon glyphicon-ok").removeClass("glyphicon glyphicon-ok").removeClass("ok");
                            $(this).find(".starrq").removeClass("warning").addClass("ok");
							$("#termcheck").addClass('ok').removeClass('warning');
				            $("#termsRequired").addClass('ok').removeClass('warning');
						}
                    
                });
            });
        /* document ready end */
   /* });

		</script>
	<script>
		$(document).ready(function(){
		*/
			$("#changepsw").on("click", function(){
				$("#login").css("display","none");
				$("#changepw").css("display","block");
				//e.preventDefault();
			});
			$("#changepsw2").on("click", function(){
				$("#login").css("display","none");
				$("#changepw").css("display","block");
				//e.preventDefault();
			});
			$("#login2").on("click", function(){
				$("#login").css("display","block");
				$("#changepw").css("display","none");
				//e.preventDefault();
			});
			
			$("#myBtn")
				.click(function () {
					$("#myModal").modal();
				});
		});
	 
    </script>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.