Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 08-26-2005, 02:19 PM Form Validation
Monkeon's Avatar
Skilled Talker

Posts: 59
Trades: 0
Hi, you've probably all been asked this a thousand times already, so I apologise in advance. The question I have is about form validation using Javascript.

I'm making a Registration page for my site. The page has the usual form fields
Username
Email
Password
Confirm Password

What I would like to know is, how to vaildate these fields in detail using javascript.
I have already got so far, but my knowledge of java is pretty bad.

Here's my code

Code:
<script type="text/javascript" language="JavaScript">
function CheckRequiredFields() {
var errormessage = new String();


// field checks

if(WithoutContent(document.form1.username.value))
	{ errormessage += "\n\nPlease choose a Username"; }
if(WithoutContent(document.form1.password.value))
	{ errormessage += "\n\nPlease choose a Password"; }
if(WithoutContent(document.form1.confirmpass.value))
	{ errormessage += "\n\nPlease confirm your Password"; }
if(WithoutContent(document.form1.email.value))
	{ errormessage += "\n\nPlease enter a valid Email address"; }
if((document.form1.confirmpass.value) != (document.form1.password.value))
	{ errormessage += "\n\nPasswords do not match"; }

	
// Error Message
if(errormessage.length > 2) {
	alert('NOTE:' + errormessage);
	return false;
	}
return true;
} // end of function CheckRequiredFields()


function WithoutContent(ss) {
if(ss.length > 0) { return false; }
return true;
}

</script>
This works fine, but I don't think it is enough. It needs to also check if the user has entered symbols into the fields. And the email field needs to be checked that it is a vaild email address.
(and if anyone has any other suggestions on what else needs to be checked, that would be great)

Can anyone tell me how to do this in Java?
Thank you!
__________________

Please login or register to view this content. Registration is FREE
FREE Online Dating!
Meet your perfect match online right now!
Monkeon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-26-2005, 03:29 PM
Experienced Talker

Posts: 44
Trades: 0
Google is your friend!
watco is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Form Validation
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09843 seconds with 12 queries