Page 1 of 1

Need JavaScrpt Code

Posted: Sun Mar 26, 2006 9:44 pm
by znad
Hi All
People I now nothing about java scripts, and i need i code imediatly..
I am looking for a code to check the text box, if its entry wasn't in an e-mail form, then an action will hapen tells the user thats its an error..

Can you help me with this?
Need JavaScrpt Code.txt

Re: Need JavaScrpt Code

Posted: Fri Mar 31, 2006 1:00 pm
by kaos_frack
znad wrote:Hi All
People I now nothing about java scripts, and i need i code imediatly..
I am looking for a code to check the text box, if its entry wasn't in an e-mail form, then an action will hapen tells the user thats its an error..

Can you help me with this?
Need JavaScrpt Code.txt
ok i can help you
assuming that you named that textbox as 'userEmail'
and assuming that your form is name 'myForm'
here's the code"

// creating a shorthand
function CheckEmail(){
var Email = ****.myForm.userEmail]{6,}@[a-z0-9-]+\.[a-z0-9]+$/i)){
alert("Invalid email address");return false;
return true;
}

good luck with your site

Posted: Fri Mar 31, 2006 3:13 pm
by Mizo
thank you ya kaos_frack about this info

Posted: Sat Apr 01, 2006 4:42 am
by kaos_frack
oh sorry i've made a little mistake
i've omitted one curle brace
it should be:
function CheckEmail()
{
var Email = ****.myForm.userEmail;
if(Email.value.search(/^[a-z0-9]{6,}@[a-z0-9-]+\.[a-z0-9]+$/i)){
alert("Invalid email address");return false;}
return true;
}

Posted: Mon Apr 17, 2006 5:27 am
by mohumben
Oh, there's another way of retrieving the textbox value, instead of ****.myForm.userEmail you can use ****.getElementById('email') (provided you defined the attribute id), I think it's easier.

Obviously this would be useless if it the form doesn't checks it. Code rewrote with slighty modifications:

Code: Select all

function checkEmail()
{ 
  var email = ****.getElementById('email'); 
  if (email.value.search(/^[a-z0-9]{6,}@[a-z0-9-]+\.[a-z0-9]+$/i)) {  
    alert("Invalid email address");
    email.focus();
    return false; 
  } else { 
    return true; 
  } 
}
Form:

Code: Select all

<form onsubmit="return checkEmail();">
Email: <input type="text" id="email" name="userEmail">
<input type="submit" value="Send">
</form>

Posted: Sat Oct 14, 2006 11:46 pm
by Holograph
I gotta learn JS some day Lol. It seems so fun

Posted: Wed Oct 25, 2006 11:55 pm
by hacker
why dont people try google once in a while?