0

I have a form which has password change functionality, the issue for a change I wrote my own controller and I change the button to type = 'button' from submit.

Now how can I validate the password? I used this $("#form-validate").validate(); on click of my button this doesn't work.

I see this script in my phtml

<script>
require([
    "jquery",
    "mage/mage"
], function($){
    var dataForm = $('#form-validate');
    var ignore = <?= /* @noEscape */ $_dob->isEnabled() ? '\'input[id$="full"]\'' : 'null' ?>;

    dataForm.mage('validation', {
    <?php if ($_dob->isEnabled()): ?>
        errorPlacement: function(error, element) {
            if (element.prop('id').search('full') !== -1) {
                var dobElement = $(element).parents('.customer-dob'),
                    errorClass = error.prop('class');
                error.insertAfter(element.parent());
                dobElement.find('.validate-custom').addClass(errorClass)
                    .after('<div class="' + errorClass + '"></div>');
            }
            else {
                error.insertAfter(element);
            }
        },
        ignore: ':hidden:not(' + ignore + ')'
    <?php else: ?>
        ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
    <?php endif ?>
    });

});

How can I validate the password fields without using form submit. I used keyup also

jQuery('.column.main.col').on('keyup','#password, #password-confirmation', function () {
    if (password.match(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@%!.])[0-9a-zA-Z@%!]{3,}$/))
        jQuery("#password_message").html("pass");
    else
        jQuery("#password_message").html("fail");

}

But this doesn't allow me to add dot . in my password Instead of doing of all this how can i use Magento form validation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.