Javascript: How to validate email address with JavaScript? Javascript: nasıl JavaScript ile email adresinizi doğrulamak için?
Posted on 13. 13 tarihinde gönderildi. Jun, 2009 by Dragos in Coding , JavaScript & Ajax Haziran, 2009 Kodlama, JavaScript ve Ajax da Dragos tarafından
Here's a piece of code I found while I was browsing the JQuery UI pages to easily validate email addresses. Burada kod ederken kolaylıkla e-posta adreslerini doğrulamak için jQuery UI sayfalarını taramaya olduğunu öğrendim bir parça's.
The code below represents a general validation function, that requires two parameters:1. Kod aşağıda, bu iki parametre: 1 gerektirir genel bir doğrulama fonksiyonunu gösterir. the string value of an obkect and 2. bir obkect ve 2 dize değeri. the regular expression to check the string against düzenli ifade dize karşı kontrol etmek
function checkRegexp(o,regexp) { fonksiyonu checkRegexp (o, regexp) ( if ( !( regexp.test( o ) ) ) { if (! (regexp.test (o))) ( return false; return false; } else { ) Else ( return true; return true; } ) } )
Now, here's the following code to use in order to validate email addresses: Şimdi, burada amacıyla e-posta adreslerini doğrulamak için kullanmak için aşağıdaki kod:
var regex=/^((([az]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([az]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([az]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([az]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([az]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([az]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([az]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([az]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([az]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([az]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i; var first=checkRegexp("email@email.",regex); //boolean false, because the email address is missing the tld var second=checkRegexp("email@email.tld",regex); //boolean true var regex =/^((([ az] | \ d | [# \ $% & '\ * \ + \ - \ / = \? \ ^ _ `(\ |}~]|[ \ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) + (\. ([az] | \ d | [# \ $% & '\ * \ + \ - \ / = \? \ ^ _ `(\ |}~]|[ \ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF ])+)*)|(( \ x22 )(((( \ x20 | \ x09) * (\ x0d \ x0a) )? (\ x20 | \ x09 )+)?(([ \ x01-\ x08 \ x0b \ x0c \ x0e-\ x1f \ x7f] | \ x21 | [\ x23-\ x5b] | [\ x5d-\ x7e ] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) | (\ \ ([\ x01-\ x09 \ x0b \ x0c \-\ x7f] | [\ u00A0-\ uD7FF \ uF900 x0d - \ uFDCF \ uFDF0-\ uFFEF ]))))*((( \ x20 | \ x09) * (\ x0d \ x0a))? (\ x20 | \ x09 )+)?( \ x22 )))@( (([az] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF ])|(([ az] | \ d | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0 - \ uFFEF]) ([az] | \ d | - | \ .|_|~|[ \ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF ])*([ az] | \ d | [ \ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]))) \ .)+(([ az] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF ])|(( [az] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]) ([az] | \ d | - | \ .|_|~|[ \ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF ])*([ az] | [\ u00A0-\ uD7FF \ uF900-\ uFDCF \ uFDF0-\ uFFEF]))) \.? $ / i; ilk var = checkRegexp ( "e-posta @ e-posta. ", regex); / / yanlış, çünkü e-posta adresi = checkRegexp tld var ikinci eksik boolean (" ", email@email.tld regex); / / true boolean It's good to validate email addresses right on the client side, because you save server resources consumption and the client is also able to correct any errors faster, without reloading the page. Çünkü sen ve istemcinin de hızlı hataları düzeltmek için mümkün ise, sayfa yeniden yüklemeden sunucu kaynaklarının tüketimi kaydetmek Bu istemci tarafında sağ tarafta e-posta adreslerini doğrulamak için, güzel. But you should never avoid rechecking the email (and not only emails) on the server side. Ama e-posta sunucu tarafında (ve sadece e-posta) yeniden denetleniyor önlemek asla.
Related posts: Ilgili posta:
- JavaScript: Send function as a parameter to another function (callbacks) JavaScript: başka fonksiyonu (geriçağırımları) için parametre olarak fonksiyonu Email
- PHP: Script to extract one's contacts from email (Gmail, Yahoo,Hotmail,AOL…) and send invites – OpenInviter to go! PHP: Script (Gmail, Yahoo, Hotmail, AOL ...) e-posta adresinden bir rehber almak ve göndermek davet etmek - OpenInviter to go!
- JavaScript: Get anchor from URL JavaScript: URL'den çapa al
- JavaScript: GIFless animation. JavaScript: GIFless animasyon. Animate images,logos with jQuery Animate görüntüler, jQuery ile logolar
- JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: jQuery ile nasıl bir nesnenin (konum bir grup içinde) kütüğü almak için?












































