/    Sign up×
Community /Pin to ProfileBookmark

email validation AND make some fields required

Hi guys,
The javascripts section has really helped me out.

First I added the “basic validation” script from [url]http://javascript.internet.com/forms/basic-validation.html[/url] and it works great! But I ALSO need to verify that email address syntax is valid. So I tried adding the “email validation basic” from [url]http://javascript.internet.com/forms/email-validation—basic.html[/url]

Now neither work. Perhaps they conflict somehow, but more likely is my <form onSubmit> syntax is incorrect.. I just added the two:
<form onSubmit=”return checkEmail(this)”;”return checkrequired(this)”>

Please correct it if you can, or suggest a new script that will check that required fields are filled AND email syntax checked.

Thanks so much!

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@CharlesAug 17.2006 — [code=html]<script type="text/javascript">
String.prototype.isEmailAddress = function () {return /^[^x00-x20()<>@,;:\".[]x7f-xff]+(?:.[^x00-x20()<>@,;:\".[]x7f-xff]+)*@[^x00-x20()<>@,;:\".[]x7f-xff]+(?:.[^x00-x20()<>@,;:\".[]x7f-xff]+)+$/.test(this)}
</script>

<input type="text" onchange="if (!this.value.isEmailAddress()) {alert ('That would not appear to be a valid email address.'); this.value=''; this.focus()}">[/code]
Copy linkTweet thisAlerts:
@naushikaaauthorAug 17.2006 — Thanks, but isn't that just to check email?
Copy linkTweet thisAlerts:
@naushikaaauthorAug 17.2006 — I replaced the email verification script I had before with the one you posted in the HEAD, and got rid of my previous ONSUBMIT.

The script I had for checking that required fields are entered now works again, but your email validation doesn't. Here's how I put it in:

<INPUT TYPE="TEXT" NAME="requiredemail" maxlength="40" size="24" value="" onchange="if

(!this.value.isEmailAddress()) {alert ('That would not appear to be a valid email

address.'); this.value=''; this.focus()}">

Is this correct?
Copy linkTweet thisAlerts:
@CharlesAug 17.2006 — Is this correct?[/QUOTE]Does it work?
Copy linkTweet thisAlerts:
@naushikaaauthorAug 17.2006 — Like I said, it doesn't work.
Copy linkTweet thisAlerts:
@CharlesAug 17.2006 — It works for me so post the URL so we can see what's going on.
Copy linkTweet thisAlerts:
@naushikaaauthorAug 17.2006 — Something weird happened..it's showing the alert now.

BUT I can still submit the form even with an invalid entry in the email section. Can this be fixed?

If you need to take a look, it's [URL]http://web.aanet.com.au/timeandwealth/[/URL]

The email form input is near the bottom of the page.

Thanks.
Copy linkTweet thisAlerts:
@CharlesAug 17.2006 — It's working just fine for me.
Copy linkTweet thisAlerts:
@naushikaaauthorAug 17.2006 — Even though it asks for a correct email address, if the submit button is pressed, it still sends it. Didn't you find?
×

Success!

Help @naushikaa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...