How to set the focus to a specific child table cell


I’m coding a client script to validate a specific cell in a child table. Upon lost focus the child field event will trigger and run the validation. If valid then the focus would have moved to the next cell, however, if invalid then I’d like the focus to return to the invalid cell. This should happen on the line with my comment

// Return the focus to the cell

function fValidateKpi(frm,cdt,cdn,field) {
    // console.log("fValidateKpi");
    var bValid = false;
    let oRegex = {'Number':"^[0-9]+$", 'Time':"^(?:2[0-3]|[01][0-9]):[0-5][0-9]$"};
    let oMessage = {
        'Number':"The Goal or Rubric is not in the correct Number format : only digits form 0 to 9",
        'Time':"The Goal or Rubric is not in the correct Time format : HH:MM"
    let regex = new RegExp(oRegex[locals[cdt][cdn]["type"]]);
    if (locals[cdt][cdn][field]) {
        bValid = regex.test(locals[cdt][cdn][field]);
    if (!bValid) {
        bAllowSave = false;
        // Return the focus to the cell
    } else {
        bAllowSave = true;

frappe.ui.form.on("PM KPI", {
    type: function(frm,cdt,cdn) {
    // We do not have a convenient way of applying a mask to the Goal and Rubric fields which is of Data fieldtype,
    //  hence we have to validate the string some time after it has lost focus
    // Unlike for master DocTypes, child table field events trigger on lost focus
    goal: function(frm,cdt,cdn) {
    over_rubric: function(frm,cdt,cdn) {
    under_rubric: function(frm,cdt,cdn) {

I have no idea as to how to achieve that. Any help will be much appreciated.