Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-05-2012, 08:04 PM   PM User | #16
chelseasikoebs
New Coder

 
Join Date: Oct 2009
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
chelseasikoebs is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
You could do

<input type = "text" id = "fullName" onblur = "validate(this)">
My input tags look like this per my book:
<input type="text" id="custEmail" name="custEmail" onblur="validate(this);">

Is having both name and id in there messing it up?
chelseasikoebs is offline   Reply With Quote
Old 12-05-2012, 08:08 PM   PM User | #17
chelseasikoebs
New Coder

 
Join Date: Oct 2009
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
chelseasikoebs is an unknown quantity at this point
My brain's getting fried! lol I may have to submit what I have with questions to my instructor and hope he gets back to me in time to get it figured out and turned in on time on Sunday. Seems like plenty of time, but for some reason online instructors aren't "online" much!
chelseasikoebs is offline   Reply With Quote
Old 12-05-2012, 08:08 PM   PM User | #18
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,102
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by chelseasikoebs View Post
Oh. Wow. I got that straight from the w3schools.com site!
You should be aware that the w3schools site is now very much out of date. As felgall says, it teaches 20th century Javascript.

Code:
<input type="text" id="custName" name="custName" onblur="validateName(this);">

<script type = "text/javascript">

function validateName (which) {
var val = which.value;
val = val.replace(/[^a-z\s\-]gi, "");  // strip all but letters (ignore case) and hyphens and spaces - Mary-Lou Smith
which.value = val;  // write it back to the field
if (val.length < 4) {
alert ("Your name must have at least 4 alpha characters");
which.focus();  // refocus on the incorrect field so compelling the user to make a valid entry
return false;
}
}
</script>
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 12-05-2012 at 09:03 PM..
Philip M is online now   Reply With Quote
Reply

Bookmarks

Tags
arrays, forms, javascript, validation

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:33 PM.


Advertisement
Log in to turn off these ads.