Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old December 30th, 2003, 03:14 PM
shnackattack shnackattack is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 60 shnackattack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
validation

Hi

Below is my html document with the validation script for the form.
I can't get the bit, that checks the numbers of characters entered, to work. what have i done wrong?

Also, how can i check that each field in the form is checked?

Thanks

Reply With Quote
  #2  
Old December 30th, 2003, 03:17 PM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: validation

Quote:
Undifined variable : "Below is my html document with the validation script for the form"


It returned when I run your script :laugh:

Reply With Quote
  #3  
Old December 30th, 2003, 08:29 PM
Andrew's Avatar
Andrew Andrew is offline
Moderator
Click here for more information. Click here for more information
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,945 Andrew User rank is Private First Class (20 - 50 Reputation Level)Andrew User rank is Private First Class (20 - 50 Reputation Level)  Folding Points: 2429 Folding Title: Novice Folder
Time spent in forums: 4 Days 5 h 58 m 47 sec
Reputation Power: 3
RE: validation

if what codekadiya said works for everyone please post code and be more specific with your questions.

Reply With Quote
  #4  
Old December 31st, 2003, 12:11 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: RE: validation


Quote:
if what codekadiya said works for everyone.


kendo,

what do you mean by that? didn't quite understand it.

Reply With Quote
  #5  
Old December 31st, 2003, 11:40 AM
shnackattack shnackattack is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 60 shnackattack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: validation

Dah, Sorry!

Forgot to post the script.
Here it is:

<html>

<head>
<title>Sign Up Form</title>
<script type="text/javascript" language="JavaScript">

function validate()
{
var str=document.register.email.value
var filter=/^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i

var min = 5
var max = 10

submitOK = "True"

if (filter.test(str) == false)
{
alert("Please input a valid email address!")
submitOK = "False"
}


if (document.username.value.length <= min || document.username.value.length >= max)
{
alert("The username must contain 5 to 10 characters!")
submitOK = "False"
}

if (submitOK == "False")
{
return false
}
}
</script>
</head>
<body>

<form name="register"
action="tryjs_submitpage.htm"
onsubmit="return validate()">

First name:
<input type="text" name="firstname">
<br>
Last name:
<input type="text" name="lastname">
<br>
Email address:
<input type="text" name="email">
<br>
Username:
<input type="text" name="username">
<br>
<input type="submit" value="Submit">
</form>

</body>

</html>




//the below part of code is from the above script.

if (document.username.value.length <= min || document.username.value.length >= max)
{
alert("The username must contain 5 to 10 characters!")
submitOK = "False"
}

I can't get the bit (part of code above), that checks the numbers of characters entered, to work. what have i done wrong?

How can i check that each field in the form is filled in? so that if the field is empty, the code will display an alert to fill in the empty field.


Thanks

Reply With Quote
  #6  
Old December 31st, 2003, 02:52 PM
Ashkhan Ashkhan is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 372 Ashkhan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 24 m 57 sec
Reputation Power: 2
RE: validation

I modified your validate function a little. It should work now.


function validate()
{
var str=document.register.email.value
var filter=/^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i

var min = 5
var max = 10

submitOK = true

if (filter.test(str) == false)
{
alert("Please input a valid email address!")
submitOK = false
}


if (document.register.username.value.length <= min || document.register.username.value.length >= max)
{
alert("The username must contain 5 to 10 characters!")
submitOK = false
}

if (document.register.firstname.value.length == 0)
{
alert("The firstname is blank!")
submitOK = false
}

if (document.register.lastname.value.length == 0)
{
alert("The lastname is blank!")
submitOK = false
}

alert(submitOK);
return submitOK;
}

Reply With Quote
  #7  
Old December 31st, 2003, 11:50 PM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 4
RE: RE: validation


Quote:
Undifined variable : "Below is my html document with the validation script for the form"

It returned when I run your script :laugh:


hehehehehe. thanks for putting a smile on my face while im stuck at work!

Reply With Quote
  #8  
Old December 31st, 2003, 11:55 PM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: RE: RE: validation

Quote:
hehehehehe. thanks for putting a smile on my face while im stuck at work!


Cool... What else did I have to say when there was nothing "below"??!!!? :laugh:
php Code:
Original - php Code
  1.  
  2. <?
  3. if(isset($htmlCode))
  4. {
  5.   echo "I will try to make a solution.";
  6. }
  7. else
  8. {
  9.  echo "Undifined variable : "Below is my html document with the validation script for the form"";
  10. }
  11. ?>

Reply With Quote
  #9  
Old January 3rd, 2004, 04:10 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: validation

Thanks for help.
It works!


Reply With Quote
  #10  
Old October 28th, 2005, 10:11 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: RE: validation

if(!/^w[w.-]+w@w([w.-]+w.)+[a-z]{3,5}$/i.test(email.value))

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > validation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT