function formValidator(){ // Make quick references to our fields var username = document.forms[0].text_Us_name; var addr = document.forms[0].text_pas; var email = document.forms[0].text_em; // Check each input in the order that it appears in the form! if(lengthRestriction(username, 6, 12)){ if(isAlphanumeric(addr, "الرقم السري ارقام وحروف")){ if(lengthaddr(addr, 4, 15)){ if(emailValidator(email, "الايميل غير صحيح")){ document.forms[0].submit(); } } } } return false; } function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; } function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function lengthRestriction(elem, min, max){ var uInput = elem.value; if(uInput.length >= min && uInput.length <= max){ return true; }else{ alert("ادخل اسم المستخدم مابين " +min+ " الى " +max+ " حروف وارقام"); elem.focus(); return false; } } function lengthaddr(elem, min, max){ var uInput = elem.value; if(uInput.length >= min && uInput.length <= max){ return true; }else{ alert("ادخل الرقم السري مابين " +min+ " الى " +max+ " حروف وارقام"); elem.focus(); return false; } } function emailValidator(elem, helperMsg){ var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(emailExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function numbersonly(e){ var unicode=e.charCode? e.charCode : e.keyCode if (unicode!=8){ if ((unicode >= 48 && unicode <= 57) || // 0-9 (unicode >= 65 && unicode <= 90) || // A-Z (unicode >= 97 && unicode <= 122)) // a-z return true; else alert("الحقل لايقبل الكتابة بالعربي") return false;} }