mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Trigger invalid on all fields, but only focus the first one. Also pass the messages across.
This commit is contained in:
parent
0cffb0c934
commit
3d36e65a55
@ -202,12 +202,15 @@ if (window.jQuery === undefined)
|
|||||||
* Focus fields with errors
|
* Focus fields with errors
|
||||||
*/
|
*/
|
||||||
if (data['X_OCTOBER_ERROR_FIELDS']) {
|
if (data['X_OCTOBER_ERROR_FIELDS']) {
|
||||||
$.each(Object.keys(data['X_OCTOBER_ERROR_FIELDS']), function(index, fieldName){
|
var foundField = false
|
||||||
|
$.each(data['X_OCTOBER_ERROR_FIELDS'], function(fieldName, fieldMessages){
|
||||||
var fieldElement = form.find('[name="'+fieldName+'"], [name$="['+fieldName+']"]').filter(':enabled').first()
|
var fieldElement = form.find('[name="'+fieldName+'"], [name$="['+fieldName+']"]').filter(':enabled').first()
|
||||||
if (fieldElement.length > 0) {
|
if (fieldElement.length > 0) {
|
||||||
fieldElement.focus()
|
if (!foundField) {
|
||||||
$(window).trigger('ajaxInvalidField', [fieldElement, fieldName])
|
fieldElement.focus()
|
||||||
return false // Break loop
|
foundField = true
|
||||||
|
}
|
||||||
|
$(window).trigger('ajaxInvalidField', [fieldElement, fieldName, fieldMessages])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user