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
Need JavaScrpt Code
-
- Posts: 504
- Joined: Sat May 07, 2005 8:03 am
- Contact:
Re: Need JavaScrpt Code
ok i can help youznad 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
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
-
- Posts: 504
- Joined: Sat May 07, 2005 8:03 am
- Contact:
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:
Form:
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;
}
}
Code: Select all
<form onsubmit="return checkEmail();">
Email: <input type="text" id="email" name="userEmail">
<input type="submit" value="Send">
</form>
Code: Select all
define('I_LOVE_PHP', true);