ms_dos10 Posted September 17, 2006 Share Posted September 17, 2006 Hi i'm new here this my frist topic on the forum & also new to javascript i hope i'll get my help here .how to valid e-mail ? i wanna more info about this object or function becouse it has () indexOf() more explain about it and charAt also . i have this code i want someone to explain it to me and i'll give u link , i'll write some code if i'm going good to vaild that email and also i wanna some help on it .http://www.w3schools.com/js/tryit.asp?file...js_formvalidatemy code here <script type="text/javascript">//here to check at simplevar email = document.frm.e_mail.valuefor(var i = 0; i <= email.lenght; i++) if(email.charAt(i) == "@") { alert("enter vaild email ") document.frm.e_mail.select() return false }//here to check dot simplefor(var j = 0; j <= email.lenght; j++) if(email.charAt(j) == ".") { alert("enter vaild email ") document.frm.e_mail.select() return false }</script> i hope i'll get my helpp over here Link to comment Share on other sites More sharing options...
scott100 Posted September 17, 2006 Share Posted September 17, 2006 Both functions are explained on the site http://www.w3schools.com/jsref/jsref_indexOf.asphttp://www.w3schools.com/jsref/jsref_charAt.asp Link to comment Share on other sites More sharing options...
ms_dos10 Posted September 17, 2006 Author Share Posted September 17, 2006 Yup both function are explained on the site but i want more explain and what i about my code (script ) can i vaild e-mail like that if no how can i do it plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me Link to comment Share on other sites More sharing options...
ms_dos10 Posted September 18, 2006 Author Share Posted September 18, 2006 no one can help i need help plzzzzzzzzzzzzzz Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 here it is in actionhttp://www.smartwebby.com/DHTML/email_validation.asp Link to comment Share on other sites More sharing options...
ms_dos10 Posted September 19, 2006 Author Share Posted September 19, 2006 thanx aspnetguy for ur help that what i want Link to comment Share on other sites More sharing options...
Webworldx Posted September 20, 2006 Share Posted September 20, 2006 I much prefer a short RegExp validation like: var theString = 'test@email.com';function testEmail(str){ var reg_email = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/; return reg_email.test(str);}var is_valid_email = testEmail(theString);alert(is_valid_email); Obviously it doesn't test correct domain extensions etc, but it's not a bad starting point. I don't really see the point in smartwebby's multiple indexOf statements, but maybe it's just me. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now