Form Validation

Form Validation

am 12.08.2009 18:21:43 von Micheleh Davis

------=_NextPart_000_002A_01CA1B47.75596020
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

Please help. My form validation worked fine until I added the terms check
at the bottom. Any ideas?



//form validation step one

function validateStep1(myForm){

// list of required fields

with (myForm) {

var requiredFields = new Array (

firstName,

lastName,

phone,

email,

terms)

}

// check for missing required fields

for (var i = 0; i < requiredFields.length; i++){

if (requiredFields[i].value == ""){

alert ("You left a required
field blank. Please enter the required information.");

requiredFields[i].focus();

return false;

}

}

// check for valid email address format

var eaddress= myForm.email.value;

var validaddress=
/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})$/;

//var validaddress= /^((\w+).?(\w+))+@\w+/i;

var result= eaddress.match(validaddress);

if (result == null) {

alert ("Please enter your complete email
address.");

myForm.email.focus();

return false;

}

// check for valid phone format

var check= myForm.phone.value;

check= check.replace(/[^0-9]/g,"");

if (check.length < 10) {

alert ("please enter your complete phone number.");

return false;

}//end if



return true;



//begin terms and conditions check

var termsCheck= myForm.terms.value;

if (bcForm1.checked == false)

{

alert ('Please read and select I Agree to
the Terms and Conditions of Service.');

return false;

}

else

{

return true;

}

//end terms check




------=_NextPart_000_002A_01CA1B47.75596020--

Re: Form Validation

am 12.08.2009 18:22:25 von Ashley Sheridan

On Wed, 2009-08-12 at 12:21 -0400, Micheleh Davis wrote:
> Please help. My form validation worked fine until I added the terms check
> at the bottom. Any ideas?
>
>
>
> //form validation step one
>
> function validateStep1(myForm){
>
> // list of required fields
>
> with (myForm) {
>
> var requiredFields = new Array (
>
> firstName,
>
> lastName,
>
> phone,
>
> email,
>
> terms)
>
> }
>
> // check for missing required fields
>
> for (var i = 0; i < requiredFields.length; i++){
>
> if (requiredFields[i].value == ""){
>
> alert ("You left a required
> field blank. Please enter the required information.");
>
> requiredFields[i].focus();
>
> return false;
>
> }
>
> }
>
> // check for valid email address format
>
> var eaddress= myForm.email.value;
>
> var validaddress=
> /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})$/;
>
> //var validaddress= /^((\w+).?(\w+))+@\w+/i;
>
> var result= eaddress.match(validaddress);
>
> if (result == null) {
>
> alert ("Please enter your complete email
> address.");
>
> myForm.email.focus();
>
> return false;
>
> }
>
> // check for valid phone format
>
> var check= myForm.phone.value;
>
> check= check.replace(/[^0-9]/g,"");
>
> if (check.length < 10) {
>
> alert ("please enter your complete phone number.");
>
> return false;
>
> }//end if
>
>
>
> return true;
>
>
>
> //begin terms and conditions check
>
> var termsCheck= myForm.terms.value;
>
> if (bcForm1.checked == false)
>
> {
>
> alert ('Please read and select I Agree to
> the Terms and Conditions of Service.');
>
> return false;
>
> }
>
> else
>
> {
>
> return true;
>
> }
>
> //end terms check
>
>
>
Erm, where's the PHP code in that?

Thanks,
Ash
http://www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Form Validation

am 12.08.2009 18:28:56 von Ralph Deffke

this is a PHP mailing list, may be u ask this on a js mailinglist

ralph_deffke@yahoo.de


""Micheleh Davis"" wrote in message
news:002901ca1b68$fc6b0020$f5410060$@COM...
> Please help. My form validation worked fine until I added the terms check
> at the bottom. Any ideas?
>
>
>
> //form validation step one
>
> function validateStep1(myForm){
>
> // list of required fields
>
> with (myForm) {
>
> var requiredFields = new Array (
>
> firstName,
>
> lastName,
>
> phone,
>
> email,
>
> terms)
>
> }
>
> // check for missing required fields
>
> for (var i = 0; i < requiredFields.length; i++){
>
> if (requiredFields[i].value == ""){
>
> alert ("You left a
required
> field blank. Please enter the required information.");
>
> requiredFields[i].focus();
>
> return false;
>
> }
>
> }
>
> // check for valid email address format
>
> var eaddress= myForm.email.value;
>
> var validaddress=
> /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})$/;
>
> //var validaddress= /^((\w+).?(\w+))+@\w+/i;
>
> var result= eaddress.match(validaddress);
>
> if (result == null) {
>
> alert ("Please enter your complete email
> address.");
>
> myForm.email.focus();
>
> return false;
>
> }
>
> // check for valid phone format
>
> var check= myForm.phone.value;
>
> check= check.replace(/[^0-9]/g,"");
>
> if (check.length < 10) {
>
> alert ("please enter your complete phone number.");
>
> return false;
>
> }//end if
>
>
>
> return true;
>
>
>
> //begin terms and conditions check
>
> var termsCheck= myForm.terms.value;
>
> if (bcForm1.checked == false)
>
> {
>
> alert ('Please read and select I Agree to
> the Terms and Conditions of Service.');
>
> return false;
>
> }
>
> else
>
> {
>
> return true;
>
> }
>
> //end terms check
>
>
>
>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Re: Form Validation

am 12.08.2009 18:42:20 von Micheleh Davis

Yep, I'm sorry, sent to the wrong one. Thanks all!


-----Original Message-----
From: Ralph Deffke [mailto:ralph_deffke@yahoo.de]
Sent: Wednesday, August 12, 2009 12:29 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Form Validation

this is a PHP mailing list, may be u ask this on a js mailinglist

ralph_deffke@yahoo.de


""Micheleh Davis"" wrote in message
news:002901ca1b68$fc6b0020$f5410060$@COM...
> Please help. My form validation worked fine until I added the terms check
> at the bottom. Any ideas?
>
>
>
> //form validation step one
>
> function validateStep1(myForm){
>
> // list of required fields
>
> with (myForm) {
>
> var requiredFields = new Array (
>
> firstName,
>
> lastName,
>
> phone,
>
> email,
>
> terms)
>
> }
>
> // check for missing required fields
>
> for (var i = 0; i < requiredFields.length; i++){
>
> if (requiredFields[i].value == ""){
>
> alert ("You left a
required
> field blank. Please enter the required information.");
>
> requiredFields[i].focus();
>
> return false;
>
> }
>
> }
>
> // check for valid email address format
>
> var eaddress= myForm.email.value;
>
> var validaddress=
> /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})$/;
>
> //var validaddress= /^((\w+).?(\w+))+@\w+/i;
>
> var result= eaddress.match(validaddress);
>
> if (result == null) {
>
> alert ("Please enter your complete email
> address.");
>
> myForm.email.focus();
>
> return false;
>
> }
>
> // check for valid phone format
>
> var check= myForm.phone.value;
>
> check= check.replace(/[^0-9]/g,"");
>
> if (check.length < 10) {
>
> alert ("please enter your complete phone number.");
>
> return false;
>
> }//end if
>
>
>
> return true;
>
>
>
> //begin terms and conditions check
>
> var termsCheck= myForm.terms.value;
>
> if (bcForm1.checked == false)
>
> {
>
> alert ('Please read and select I Agree to
> the Terms and Conditions of Service.');
>
> return false;
>
> }
>
> else
>
> {
>
> return true;
>
> }
>
> //end terms check
>
>
>
>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: Form Validation

am 12.08.2009 22:00:15 von Ralph Deffke

may I ask what JS list u are using?

""Micheleh Davis"" wrote in message
news:003901ca1b6b$dd103d00$9730b700$@COM...
> Yep, I'm sorry, sent to the wrong one. Thanks all!
>
>
> -----Original Message-----
> From: Ralph Deffke [mailto:ralph_deffke@yahoo.de]
> Sent: Wednesday, August 12, 2009 12:29 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: Form Validation
>
> this is a PHP mailing list, may be u ask this on a js mailinglist
>
> ralph_deffke@yahoo.de
>
>
> ""Micheleh Davis"" wrote in message
> news:002901ca1b68$fc6b0020$f5410060$@COM...
> > Please help. My form validation worked fine until I added the terms
check
> > at the bottom. Any ideas?
> >
> >
> >
> > //form validation step one
> >
> > function validateStep1(myForm){
> >
> > // list of required fields
> >
> > with (myForm) {
> >
> > var requiredFields = new Array (
> >
> > firstName,
> >
> > lastName,
> >
> > phone,
> >
> > email,
> >
> > terms)
> >
> > }
> >
> > // check for missing required fields
> >
> > for (var i = 0; i < requiredFields.length; i++){
> >
> > if (requiredFields[i].value == ""){
> >
> > alert ("You left a
> required
> > field blank. Please enter the required information.");
> >
> >
requiredFields[i].focus();
> >
> > return false;
> >
> > }
> >
> > }
> >
> > // check for valid email address format
> >
> > var eaddress= myForm.email.value;
> >
> > var validaddress=
> > /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})$/;
> >
> > //var validaddress= /^((\w+).?(\w+))+@\w+/i;
> >
> > var result= eaddress.match(validaddress);
> >
> > if (result == null) {
> >
> > alert ("Please enter your complete email
> > address.");
> >
> > myForm.email.focus();
> >
> > return false;
> >
> > }
> >
> > // check for valid phone format
> >
> > var check= myForm.phone.value;
> >
> > check= check.replace(/[^0-9]/g,"");
> >
> > if (check.length < 10) {
> >
> > alert ("please enter your complete phone number.");
> >
> > return false;
> >
> > }//end if
> >
> >
> >
> > return true;
> >
> >
> >
> > //begin terms and conditions check
> >
> > var termsCheck= myForm.terms.value;
> >
> > if (bcForm1.checked == false)
> >
> > {
> >
> > alert ('Please read and select I Agree
to
> > the Terms and Conditions of Service.');
> >
> > return false;
> >
> > }
> >
> > else
> >
> > {
> >
> > return true;
> >
> > }
> >
> > //end terms check
> >
> >
> >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Form Validation

am 13.08.2009 10:33:21 von metastable

Ashley Sheridan wrote:
> On Wed, 2009-08-12 at 12:21 -0400, Micheleh Davis wrote:
>
>> Please help. My form validation worked fine until I added the terms check
>> at the bottom. Any ideas?
>>
>>
>>
>> //form validation step one
>>
>> function validateStep1(myForm){
>>
>> // list of required fields
>>
>> with (myForm) {
>>
>> var requiredFields = new Array (
>>
>> firstName,
>>
>> lastName,
>>
>> phone,
>>
>> email,
>>
>> terms)
>>
>> }
>>
>> // check for missing required fields
>>
>> for (var i = 0; i < requiredFields.length; i++){
>>
>> if (requiredFields[i].value == ""){
>>
>> alert ("You left a required
>> field blank. Please enter the required information.");
>>
>> requiredFields[i].focus();
>>
>> return false;
>>
>> }
>>
>> }
>>
>> // check for valid email address format
>>
>> var eaddress= myForm.email.value;
>>
>> var validaddress=
>> /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})$/;
>>
>> //var validaddress= /^((\w+).?(\w+))+@\w+/i;
>>
>> var result= eaddress.match(validaddress);
>>
>> if (result == null) {
>>
>> alert ("Please enter your complete email
>> address.");
>>
>> myForm.email.focus();
>>
>> return false;
>>
>> }
>>
>> // check for valid phone format
>>
>> var check= myForm.phone.value;
>>
>> check= check.replace(/[^0-9]/g,"");
>>
>> if (check.length < 10) {
>>
>> alert ("please enter your complete phone number.");
>>
>> return false;
>>
>> }//end if
>>
>>
>>
>> return true;
>>
>>
>>
>> //begin terms and conditions check
>>
>> var termsCheck= myForm.terms.value;
>>
>> if (bcForm1.checked == false)
>>
>> {
>>
>> alert ('Please read and select I Agree to
>> the Terms and Conditions of Service.');
>>
>> return false;
>>
>> }
>>
>> else
>>
>> {
>>
>> return true;
>>
>> }
>>
>> //end terms check
>>
>>
>>
>>
> Erm, where's the PHP code in that?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
Indeed. And I hope that there is server-side form validation also.

HTH,

Stijn

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php