?
avatar Serhioromano
Serhioromano
11 Apr 2018

In one of my JS scripts I call on frontend

MyExtension.submitbutton = function(task) {
	if(task == 'emgroup.cancel' || document.formvalidator.isValid('#item-form')) {
		Emerald.submitform(task, document.getElementById('item-form'));
	} else {
		alert('Invalid form');
	}
}

Pay attention to document.formvalidator.isValid

So I get this

2018-04-11_21-13-57

The problem is in validate.js

2018-04-11_21-16-19

Steps to reproduce the issue

add to your page

<script>
    function submit_test() {
        if(document.formvalidator.isValid('#item-form')) {
            console.log('Ok');
        }
    }
</script>
<form method="post" name="adminForm" id="item-form" class="form-validate form-horizontal">
    <button type="button" class="btn-submit btn btn-primary" onclick="submit_test();">Apply</button>
    <input type="text" name="jform[name]" id="jform_name" value="" required>
</form>	

Expected result

Console log print OK

Actual result

Error

System information (as much as possible)

Windows 7 SP1
Latest Chrome

Additional comments

No

avatar Serhioromano Serhioromano - open - 11 Apr 2018
avatar joomla-cms-bot joomla-cms-bot - change - 11 Apr 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Apr 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 11 Apr 2018
Category JavaScript
avatar Serhioromano
Serhioromano - comment - 11 Apr 2018

Looks like I can fix it by changing

document.formvalidator.isValid('#item-form')

to

document.formvalidator.isValid(document.getElementById('item-form'))

You can close this issue.

avatar Serhioromano Serhioromano - change - 11 Apr 2018
Status New Closed
Closed_Date 0000-00-00 00:00:00 2018-04-11 16:13:37
Closed_By Serhioromano
avatar Serhioromano Serhioromano - close - 11 Apr 2018

Add a Comment

Login with GitHub to post a comment