HAN! Posted October 16, 2007 Share Posted October 16, 2007 i need to check the validation of e-mail posted in a form just to be written in the write way (aaaa@aaa.com) so what do i have to use javascripts or.... help plz Quote Link to comment https://forums.phpfreaks.com/topic/73460-solved-i-need-some-help/ Share on other sites More sharing options...
jeeva Posted October 16, 2007 Share Posted October 16, 2007 Try this.. var str=form.email.value var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (filter.test(str)) testresults=true else{ alert("Please enter a valid email address!") return false; } Quote Link to comment https://forums.phpfreaks.com/topic/73460-solved-i-need-some-help/#findComment-370556 Share on other sites More sharing options...
hostfreak Posted October 16, 2007 Share Posted October 16, 2007 Or/And with php (javascript can be disabled): <?php $email = 'aaaaa@aaa.com'; $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$"; if (!eregi($regex,$email)) { echo 'Errror: Invalid email<br />'; } else { //continue } ?> Quote Link to comment https://forums.phpfreaks.com/topic/73460-solved-i-need-some-help/#findComment-370561 Share on other sites More sharing options...
kenrbnsn Posted October 16, 2007 Share Posted October 16, 2007 That is Javascript and will not get executed if someone disables Javascript or is spoofing the form. If you search for "php email validation" in your favorite search engine, I'm sure you will find something you can use. Ken Quote Link to comment https://forums.phpfreaks.com/topic/73460-solved-i-need-some-help/#findComment-370563 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.