when put greek characters in name field on send contact form returns error report. so, how edit validation form accept greek characters in both name & message fields?
function validation() { var contactname = document.forms["contactfrm"]["name"].value; var name_exp = /^[a-za-z\s]+$/; if (contactname == '') { swal("you forgot name...", " ", "warning"); document.forms["contactfrm"]["name"].focus(); return false; } else if (!contactname.match(name_exp)) { swal("invalid name...", " ", "error"); document.forms["contactfrm"]["name"].focus(); return false; } var email = document.forms["contactfrm"]["email"].value; //var email_exp = /^[a-za-z0-9\.-_\$]+@[a-za-z]+\.[a-z]{2,4}$/; var email_exp = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if (email == '') { swal("you forgot enter email...", " ", "warning"); document.forms["contactfrm"]["email"].focus(); return false; } else if (!email.match(email_exp)) { swal("your email address invalid...", " ", "error"); document.forms["contactfrm"]["email"].focus(); return false; } var message = document.forms["contactfrm"]["comments"].value; if (message == '') { swal("no empty messages, please...", "warning"); document.forms["contactfrm"]["comments"].focus(); return false; } return true; }
you can achieve changing name expression to:
name_exp=/^[a-za-zΑ-Ωα-ωίϊΐάέήόύϋΰώΆΈΉΌΏΎΫ\s]+$/;
and email expression to:
//var email_exp=/^[a-za-z0-9\.-_\$]+@[a-za-z]+\.[a-z]{2,4}$/; var email_exp=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
Comments
Post a Comment