JSFiddle - React, Tailwind, and code Playground
HTML
<form id='form'>
<input type='text' name='file' id='file'/>
<input type='submit'/>
</form>
JavaScript
document.getElementById("form").onsubmit = function(ev)
{
var file_path = document.getElementById("file").value;
var img = document.createElement('img');
img.setAttribute('src', file_path);
img.onerror = function()
{
window.alert("Not correct file path");
ev.preventDefault();
}
}