validate number and improve form submit control flow