Bs 3 modal form events with jquery

I needed to to correct the code but still is not working. I guess I need a variable to store password detail otherwise inputattr changes at every input.

if (inputattr === "Retype Password") {
									alert(inputattr);
										if (inputstr.length > 0) {
										   if (inputstr != inputs.Password.inputattr) {
												$(this).find(".error").html(inputattr + " is Incorrect: Password doesn't match retyped pwd ");
												$(this).find(".error").addClass('warning').removeClass('ok');
												//$(this).css("border","2px solid red");
												} else {
												$(this).find(".error").html(inputattr+" is OK: Your data has been entered correctly "+inputstr);
												$(this).find(".error").addClass('ok').removeClass('warning');
												//$(this).css("border","2px solid green");
												}			
											 
											  								  
											 // var pswReglow = /^([a-zA-Z0-9]{6,})+$/;
											 // var pswRegheigh = /^([a-zA-Z0-9]{13,})+$/;//13 or more occurences
													
											}else{
												$(this).find(".error").html(inputattr+" is EMPTY: Please enter data into this input");
												$(this).find(".error").addClass('warning').removeClass('ok');
												//$(this).css("border","2px solid red");
											}
											
										}

You placed it after the retype if statement. That is the opposite of what I said.

This is a mistake.

Here is how it needs to be for you to learn what’s happening with the retype password issue:

1 Like

Hi Paul
thank you for help. I copy and pasted the code and opened chrome more tools and dev tools and tried the modal but I don’t know how to test the code. can you tell me the next step?thank you.

Well what is the problem that you are trying to solve?

trying the code you gave to solve the problem I mentioned above. retype password is not working, that means as I retype password that should match password above, at the first mistyped pwd I should get error msg. thank you.

Hold on, there’s a misunderstanding here. I am not solving the problem for you. The code I gave isn’t intended to directly solve the problem.

Instead, I am trying to get you tools so that you can attempt to understand what’s causing the problem.

2 Likes

So with that console.log statement before the “Retype Password” if statement, what do you see in the console when you enter something into the retype field?

1 Like

in chrome more tools dev tools console log I can see changed only at every keystroke
" inputattr at retype password: Password retype
modalloginsignupjquery2.html:669 changed "

Your last link to codePen code shows something different.

Can you please supply a more recent link to the codePen code where you see that?

yes I updated my code on codepen, thank you

Thanks. When interacting with the retype password field, the console command says that inputattr is the string Password retype whereas the if statement is looking for the string Retype Password

Does that help to inform you about what the problem is?

the only thing I understand is that input content changes at every keystroke, but if I need to compare its content with password input, I need to ‘access’ it I guess this is called referencing. theoretically it is done, previously you gave help but the same code adapted is not working, most likely there is a mistake. can you help me with it? thank you.

I have one question for you.

When the retype password content changes, what is the inputattr string?

as I type something in retype password field, this is the console msg
‘changed
modalloginsignupjquery2.html:738 inputattr at retype password: Password retype
modalloginsignupjquery2.html:669 changed
modalloginsignupjquery2.html:738 inputattr at retype password: Password retype’

Okay, and can you figure out what the inputattr string is from that?

inputattr at retype password

No, that isn’t the inputattr string. Here, let me give you a hint.

The code that outputs that console message is:

console.log("inputattr at retype password:", inputattr);

And the console message is:

inputattr at retype password: Password retype

Is that enough information to help you to figure out the string value of inputattr ?

it is Password Retype, as it is appearing under the input field beside green star. if I am right

Now look at the if statement. Here is the if statement.

if (inputattr === "Retype Password") {

Once again, here is the inputattr string: “Password retype”

Can you spot the difference?