Skip to content

Commit d54f459

Browse files
Bug Fix
- Stop moving submit buttons on hover/active which is risky - Added delayed focus helper - Removed direct formField.focus() from the affected validators - Moved focus handling into SaveCombinedConfig()
1 parent 90844b0 commit d54f459

1 file changed

Lines changed: 57 additions & 13 deletions

File tree

MerlinAU.asp

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ input[type="submit"] {
232232
button:hover,
233233
input[type="button"]:hover,
234234
input[type="submit"]:hover {
235-
transform: translateY(-1px);
236235
background: linear-gradient(135deg, #3b98ba 0%, #28728e 100%) !important;
237236
box-shadow: 0 8px 18px rgba(0,0,0,0.35);
238237
}
@@ -241,7 +240,6 @@ input[type="submit"]:hover {
241240
button:active,
242241
input[type="button"]:active,
243242
input[type="submit"]:active {
244-
transform: translateY(0);
245243
box-shadow: 0 3px 8px rgba(0,0,0,0.30);
246244
}
247245
@@ -338,6 +336,27 @@ const scriptUpdateGateMaxTries = 12;
338336
339337
const validationErrorMsg = 'Validation failed. Please correct invalid value and try again.';
340338
339+
function FocusInvalidFieldAfterAlert(formField)
340+
{
341+
if (formField === null || typeof formField === 'undefined')
342+
{ return; }
343+
344+
setTimeout(function()
345+
{
346+
try
347+
{
348+
formField.focus();
349+
350+
if (typeof formField.select === 'function')
351+
{ formField.select(); }
352+
}
353+
catch (error)
354+
{
355+
ConsoleLogDEBUG('Unable to focus invalid field:', error);
356+
}
357+
}, 0);
358+
}
359+
341360
/**-------------------------------------**/
342361
/** Added by Martinski W. [2025-Feb-21] **/
343362
/**-------------------------------------**/
@@ -400,6 +419,9 @@ const fwPostponedDays =
400419
/**-------------------------------------**/
401420
function ValidatePostponedDays (formField)
402421
{
422+
if (formField === null || typeof formField === 'undefined')
423+
{ return false; }
424+
403425
if (fwPostponedDays.ValidateNumber(formField))
404426
{
405427
$(formField).removeClass('Invalid');
@@ -408,8 +430,8 @@ function ValidatePostponedDays (formField)
408430
}
409431
else
410432
{
411-
formField.focus();
412433
$(formField).addClass('Invalid');
434+
$(formField).off('mouseover');
413435
$(formField).on('mouseover',function(){return overlib(fwPostponedDays.ErrorMsg(),0,0);});
414436
$(formField)[0].onmouseout = nd;
415437
return false;
@@ -598,6 +620,9 @@ function RunScriptUpdateFirmwareGateCheck()
598620
/**-------------------------------------**/
599621
function ValidateFWUpdateTime (formField, timeInput)
600622
{
623+
if (formField === null || typeof formField === 'undefined')
624+
{ return false; }
625+
601626
if (fwScheduleTime.ValidateTime (formField, timeInput))
602627
{
603628
$(formField).removeClass('Invalid');
@@ -606,8 +631,8 @@ function ValidateFWUpdateTime (formField, timeInput)
606631
}
607632
else
608633
{
609-
formField.focus();
610634
$(formField).addClass('Invalid');
635+
$(formField).off('mouseover');
611636
$(formField).on('mouseover',function(){return overlib(fwScheduleTime.ErrorMsg(timeInput),0,0);});
612637
$(formField)[0].onmouseout = nd;
613638
return false;
@@ -619,6 +644,9 @@ function ValidateFWUpdateTime (formField, timeInput)
619644
/**-------------------------------------**/
620645
function ValidateFWUpdateXDays (formField, timeInput)
621646
{
647+
if (formField === null || typeof formField === 'undefined')
648+
{ return false; }
649+
622650
if (fwScheduleTime.ValidateTime (formField, timeInput))
623651
{
624652
$(formField).removeClass('Invalid');
@@ -627,8 +655,8 @@ function ValidateFWUpdateXDays (formField, timeInput)
627655
}
628656
else
629657
{
630-
formField.focus();
631658
$(formField).addClass('Invalid');
659+
$(formField).off('mouseover');
632660
$(formField).on('mouseover',function(){return overlib(fwScheduleTime.ErrorMsg(timeInput),0,0);});
633661
$(formField)[0].onmouseout = nd;
634662
return false;
@@ -1322,7 +1350,8 @@ function ToggleChangelogApproval (checkboxElem)
13221350
/**----------------------------------------**/
13231351
function ValidateDirectoryPath (formField, dirType)
13241352
{
1325-
if (formField === null) { return false; }
1353+
if (formField === null || typeof formField === 'undefined')
1354+
{ return false; }
13261355
13271356
if (fwUpdateDirPath.ValidatePath(formField, dirType))
13281357
{
@@ -1332,8 +1361,8 @@ function ValidateDirectoryPath (formField, dirType)
13321361
}
13331362
else
13341363
{
1335-
formField.focus();
13361364
$(formField).addClass('Invalid');
1365+
$(formField).off('mouseover');
13371366
$(formField).on('mouseover',function(){return overlib(fwUpdateDirPath.ErrorMsg(dirType),0,0);});
13381367
$(formField)[0].onmouseout = nd;
13391368
return false;
@@ -2594,29 +2623,42 @@ function SaveCombinedConfig()
25942623
if (!ValidatePasswordString(passwordElem, 'onSAVE'))
25952624
{
25962625
alert(`${validationErrorMsg}\n\n` + loginPassword.ErrorMsg());
2626+
FocusInvalidFieldAfterAlert(passwordElem);
25972627
return false;
25982628
}
2599-
if (!ValidatePostponedDays(document.form.fwUpdatePostponement))
2629+
2630+
let fwUpdatePostponement = document.form.fwUpdatePostponement;
2631+
if (!ValidatePostponedDays(fwUpdatePostponement))
26002632
{
26012633
alert(`${validationErrorMsg}\n\n` + fwPostponedDays.ErrorMsg());
2634+
FocusInvalidFieldAfterAlert(fwUpdatePostponement);
26022635
return false;
26032636
}
2604-
if (document.form.fwScheduleHOUR.disabled === false &&
2605-
!ValidateFWUpdateTime(document.form.fwScheduleHOUR, 'HOUR'))
2637+
2638+
let fwScheduleHOUR = document.form.fwScheduleHOUR;
2639+
if (fwScheduleHOUR.disabled === false &&
2640+
!ValidateFWUpdateTime(fwScheduleHOUR, 'HOUR'))
26062641
{
26072642
alert(`${validationErrorMsg}\n\n` + fwScheduleTime.ErrorMsg('HOUR'));
2643+
FocusInvalidFieldAfterAlert(fwScheduleHOUR);
26082644
return false;
26092645
}
2610-
if (document.form.fwScheduleMINS.disabled === false &&
2611-
!ValidateFWUpdateTime(document.form.fwScheduleMINS, 'MINS'))
2646+
2647+
let fwScheduleMINS = document.form.fwScheduleMINS;
2648+
if (fwScheduleMINS.disabled === false &&
2649+
!ValidateFWUpdateTime(fwScheduleMINS, 'MINS'))
26122650
{
26132651
alert(`${validationErrorMsg}\n\n` + fwScheduleTime.ErrorMsg('MINS'));
2652+
FocusInvalidFieldAfterAlert(fwScheduleMINS);
26142653
return false;
26152654
}
2655+
2656+
let fwScheduleXDAYS = document.form.fwScheduleXDAYS;
26162657
if (document.getElementById('fwSchedBoxDAYSX').checked &&
2617-
!ValidateFWUpdateXDays(document.form.fwScheduleXDAYS, 'DAYS'))
2658+
!ValidateFWUpdateXDays(fwScheduleXDAYS, 'DAYS'))
26182659
{
26192660
alert(`${validationErrorMsg}\n\n` + fwScheduleTime.ErrorMsg('DAYS'));
2661+
FocusInvalidFieldAfterAlert(fwScheduleXDAYS);
26202662
return false;
26212663
}
26222664
@@ -2668,6 +2710,7 @@ function SaveCombinedConfig()
26682710
}
26692711
else {
26702712
alert(`${validationErrorMsg}\n\n` + fwUpdateDirPath.ErrorMsg('ZIP'));
2713+
FocusInvalidFieldAfterAlert(fwUpdateZIPdirectory);
26712714
return false;
26722715
}
26732716
}
@@ -2681,6 +2724,7 @@ function SaveCombinedConfig()
26812724
}
26822725
else {
26832726
alert(`${validationErrorMsg}\n\n` + fwUpdateDirPath.ErrorMsg('LOG'));
2727+
FocusInvalidFieldAfterAlert(fwUpdateLOGdirectory);
26842728
return false;
26852729
}
26862730
}

0 commit comments

Comments
 (0)