F
F
Ferret Common2018-02-11 16:15:14
JavaScript
Ferret Common, 2018-02-11 16:15:14

Pattern, pattern?

I am making a registration page. I came across the "Password Confirmation" field. Yuzayu script, it turns out to make this field. Here is the script:

function checkPP() {
                        if (document.getElementById('pass').value != document.getElementById('conf').value) {
                            alert ("Пароль и Подтверждение пароля не совпадают!")
                        }
                        else {
                            document.forms['forma'].submit();
                        }
                    }

pass is the password entered for the first time, conf is the second time, form is all fields. Well, there name, login ... So. If earlier I inserted "required" and the "pattern" template into each input line, then all the template and bindings fell off! That is, an alert flies out, but if nothing is written in all fields (or written not according to the template), no notification like "Fill in this field" flies out!!! How can this be fixed? Help pliz

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivanq, 2018-02-13
@Ivanq

function checkPP() {
                    if (document.getElementById('pass').value != document.getElementById('conf').value) {
                        alert ("Пароль и Подтверждение пароля не совпадают!")
                    }
                    else {
                        document.forms['forma'].submit();
                    }
                }

->
function checkPP(e) {
                    if (document.getElementById('pass').value != document.getElementById('conf').value) {
                        alert ("Пароль и Подтверждение пароля не совпадают!")
                        e.preventDefault();
                    }
                }

->
onclick="checkPP(event)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question