sharepoint designer – create a validation after adding a line

based on the federal state selection city, the 2nd row is not bound.

var categoryinfo = {
"Andhra-Pradesh": {
"Vijayawada":[],
"Visakhapatnam"[],
"Kadapa":[]
},

"Maharastra": {
"Mumbai":[],
"Pune":[]
},
"Telangana": {
"Secunderabad"[],
"Hyderabad":[],
"Khammam"[]
},
}


$ (Document) .ready (function () {
getlists ();
});
Function getlists () {
var stateSel = document.getElementById ("stateSel");
var citySel = document.getElementById ("citySel");
for (var state in categoryinfo) {
stateSel.options[stateSel.options.length] = new option (state,
State);
}
stateSel.onchange = function () {
citySel.length = 1;
if (this.selectedIndex <1) {
citySel.options[0].text = "Please select state."
Return;
}
citySel.options[0].text = "Please select city."
for (var city in categoryinfo[this.value]) {
citySel.options[citySel.options.length] = new option (city, city);
}
if (citySel.options.length == 2) {
citySel.selectedIndex = 1;

}

}

}


// insert data

siteurl = "https://neodadar1.sharepoint.com/sites/Masterpage1";
Insert function () {
var clientcontext = new SP.ClientContext (siteurl);
var list = clientcontext.get_web (). get_lists (). getByTitle (& # 39; task & # 39;);
var itemCreateInfo = new SP.ListItemCreationInformation ();
var state = document.getElementById (& # 39; stateSel & # 39;). value;
var city = document.getElementById (& # 39; citySel & # 39;). value;
this.oListItem = list.addItem (itemCreateInfo);
oListItem.set_item (& # 39; state & # 39 ;, state);
oListItem.set_item (& # 39; city & # 39 ;, city);
oListItem.update ();
clientcontext.load (oListItem);
clientcontext.executeQueryAsync (Function.createDelegate (this, this.onQuerySucceeded), Function.createDelegate (this, this.onQueryFailed));
}
Function onQuerySucceeded ()
{
alert (& # 39; article successfully created & # 39;);
}

Function onQueryFailed (Sender, Arguments)
{
alert (& # 39; request failed. & # 39; + args.get_message () + & # 39; + args.get_stackTrace ());
}

// redirect to another page

Function Redirect ()
{
window.location = "https://neodadar1.sharepoint.com/sites/Masterpage1/SitePages/gridtask.aspx";
}


// validations

Function ddlValidate () {
var e = document.getElementById ("stateSel");
var optionSelIndex = e.options[e.selectedIndex].Value;
var optionSelectedText = e.options[e.selectedIndex].Text;
if (optionSelIndex == 0) {
alert ("Please select a state");
return it incorrectly;
}
var e = document.getElementById ("citySel");
var optionSelIndex = e.options[e.selectedIndex].Value;
var optionSelectedText = e.options[e.selectedIndex].Text;
if (optionSelIndex == 0) {
alert ("Please select a city");
return it incorrectly;
}
insert();
}


$ (Document) .ready (function () {
$ ("# addrow"). click (function () {
var e = document.getElementById ("stateSel");
var optionSelIndex = e.options[e.selectedIndex].Value;
var optionSelectedText = e.options[e.selectedIndex].Text;
if (optionSelIndex == 0) {
alert ("Please select a state");
return it incorrectly;
}
var e = document.getElementById ("citySel");
var optionSelIndex = e.options[e.selectedIndex].Value;
var optionSelectedText = e.options[e.selectedIndex].Text;
if (optionSelIndex == 0) {
alert ("Please select a city");
return it incorrectly;
}

addRow ("tbl");
});
var addRow = function (tbl) {
var table = document.getElementById (tbl);
var rowCount = table.rows.length;
var row = table.insertRow (rowCount);
var colCount = table rows[0]Zellen.Länge;

for (var i = 0; i <colCount; i ++) {
var newcell = row.insertCell (i);

newcell.innerHTML = table.rows[0].Zellen[i].innerHTML;
newcell.childNodes[0].selectedIndex = 0;
}
};
});

Look at ** strong text ** here