I f there are not too many (subjective judgement required here) you could create a list box or dropdown so they can only select a correct one in the first place.
Otherwise
select devicenum from table where devicenum = $_POST['devicenum']"
and check the number or recs returned > 0 to see if exists.
Output error messge when you redisplay the form