Here the sample code to check whether the opportunity name already exists, if it exist then it will show an error.
However, if you are not added return values, then it struck in the same field and page also not support to enter the next fields.
function fieldChanged(scriptContext) {
    try {   
let currentRecord = scriptContext.currentRecord;
if (scriptContext.fieldId === ‘title’) {
let opportunityName = currentRecord.getValue(‘title’);
//call the checkTitleExist function
let titleExists = checkTitleExists(opportunityName);
if (titleExists && checkForParameter(opportunityName)) {
alert (“The opportunity name is already exists. Please enter the different name”);
currentRecord.setValue({
fieldId: ‘title’,
value: ”
});
return false;
}
return true;
}
} catch (error) {               
log.error(“error@fieldChanged”, error);
}
}