You can use persianRex, it detects all Persian characters in different keyboard layouts and it's open source.
Download it and put it in your project folder. Then include it in your HTML like this:
<script src="persian-rex/dist/persian-rex.js"></script>
Then in your Javascript you can do this:
function Just_persian(str){
if(persianRex.text.test(str))
alert("not format");
}