function checkEmail(eMail) { var pattern = /^[\_]*([a-zA-Z0-9]+(\.|\_*)?)+@([a-zA-Z0-9][a-zA-Z0-9\-]+(\.|\-*\.))+[a-zA-Z]{2,6}$/; return pattern.test(eMail); } function checkPhone(phone) { if(phone.length<7) return false; for (var i = 0; i < phone.length; i++) { if ( ( (phone.charAt(i) < "0") || (phone.charAt(i) > "9") ) && (phone.charAt(i) != "-") && (phone.charAt(i) != "+") ) return false; } return true; } function checkName(name) { for( var i=0; i < name.length; i++ ) { if((name.charAt(i)>='0' && name.charAt(i)<='9') || name.charAt(i) == '/' || name.charAt(i) == '\\' || name.charAt(i) == ',' || name.charAt(i) == '.' || name.charAt(i) == '=' || name.charAt(i) == '+' || name.charAt(i) == ':' || name.charAt(i) == ';' || name.charAt(i) == '|' || name.charAt(i) == '#' || name.charAt(i) == '$' || name.charAt(i) == '%' || name.charAt(i) == '^' || name.charAt(i) == '&' || name.charAt(i) == '*' || name.charAt(i) == '(' || name.charAt(i) == ')' || name.charAt(i) == '_' || name.charAt(i) == '[' || name.charAt(i) == ']' || name.charAt(i) == '{' || name.charAt(i) == '}' || name.charAt(i) == '~' || name.charAt(i) == '@' ) { return true; } } return false } function checkForm() { if(document.getElementById('fullName').value=="" || document.getElementById('fullName').value=="שם מלא") { alert(".נא למלא שם מלא *"); document.getElementById('fullName').focus(); return false; } if(checkName(document.getElementById('fullName').value) ) { alert(".שם מלא יכול להכיל אותיות בלבד *"); document.getElementById('fullName').focus(); return false; } if(document.getElementById('eMail').value=="" || document.getElementById('eMail').value=='דוא"ל') { alert(".נא למלא דוא\"ל *"); document.getElementById('eMail').focus(); return false; } if(document.getElementById('eMail').value != '' && document.getElementById('eMail').value!='דוא"ל') { if(!checkEmail(document.getElementById('eMail').value)) { alert('.כתובת דוא\"ל אינה תקינה *'); document.getElementById('eMail').focus(); return false; } } if(document.getElementById('phone').value=="" || document.getElementById('phone').value=="טלפון") { alert(".נא למלא טלפון *"); document.getElementById('phone').focus(); return false; } if(document.getElementById('phone').value!='' || document.getElementById('phone').value=="טלפון") { if(!checkPhone(document.getElementById('phone').value)) { alert("מספר טלפון אינו תקין *"); document.getElementById('phone').focus(); return false; } } if(document.getElementById('message').value=="" || document.getElementById('message').value=="הודעה") { alert(".נא למלא הודעה *"); document.getElementById('message').focus(); return false; } return true; } function checkFormSearch() { if(document.getElementById('search_text').value=="" || document.getElementById('search_text').value=="חיפוש באתר") { alert(".נא למלא טקסט לחיפוש *"); document.getElementById('search_text').focus(); return false; } return true; } $(function() { $("#eMail").keypress(function() { $(this).attr("value", jQuery.trim($(this).attr("value"))); }); $("#eMail").focus(function() { if($(this).attr("value") == 'דוא"ל') $(this).attr("value", ''); }).blur(function() { if($(this).attr("value") == '') $(this).attr("value", 'דוא"ל'); }); $("#fullName").focus(function() { if($(this).attr("value") == 'שם מלא') $(this).attr("value", ''); }).blur(function() { if($(this).attr("value") == '') $(this).attr("value", 'שם מלא'); }); $("#company").focus(function() { if($(this).attr("value") == 'חברה') $(this).attr("value", ''); }).blur(function() { if($(this).attr("value") == '') $(this).attr("value", 'חברה'); }); $("#phone").focus(function() { if($(this).attr("value") == 'טלפון') $(this).attr("value", ''); }).blur(function() { if($(this).attr("value") == '') $(this).attr("value", 'טלפון'); }); $("#message").focus(function() { if($(this).attr("value") == 'הודעה') $(this).attr("value", ''); }).blur(function() { if($(this).attr("value") == '') $(this).attr("value", 'הודעה'); }); $(".search_text").focus(function() { if($(this).attr("value") == 'הודעה') $(this).attr("value", ''); }).blur(function() { if($(this).attr("value") == '') $(this).attr("value", 'הודעה'); }); });