Buy Sell Discuss UK Domain Names at AcornDomains.co.uk

Today's Drop Dates are: 19-02-2012 or 26-02-2012   All times are GMT. The time now is 12:43:32 PM.
Domain Name Sales Domain Software Calculate UK Domain Drop Dates Domain Registration NameDrive Domain Parking Subscribe to our Domains For Sale newsletter
Go Back   Domain Forum Acorn Domains Buy Sell Auction UK Domains > Website Design and Promotion > Website Design > Scripts and Coding
Connect with Facebook

Scripts and Coding PHP, MySQL, scripts

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 10-11-2010, 03:13:45 PM     #1 (permalink)

 
pbryd's Avatar
 
Join Date: Mar 2007
Location: Newcastle
Posts: 348
pbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond repute

javascript check form

I've got a bit of javascript to to check a field in a form on my web page.

It's a competition so I need to make sure the visitor types it in correctly.

the javascript to check the 'answer' field is

Code:
 if (form.answer.value != "brabantia") {	
    alert( "oops! try again?" );
    form.answer.focus();	
    return false ;
  }
  return true ;
}
but this is case sensitive.

I'd like to add some kind of other check for "Brabantia" too.

The javascript needs to return true whether the visitor enters 'brabantia' or 'Brabantia'

Any help?

Phil
pbryd is offline  
Old 10-11-2010, 06:16:51 PM     #2 (permalink)
Member
 
Join Date: Apr 2010
Location: Buenos Aires
Posts: 83
JDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond reputeJDubya has a reputation beyond repute

PHP Code:
if (form.answer.value != "brabantia" && form.answer.value != "Brabantia") {    
    
alert"oops! try again?" );
    
form.answer.focus();    
    return 
false ;
  }
  return 
true ;

Just modifying the if condition to check for both...

Probably I would use match() http://www.w3schools.com/jsref/jsref_match.asp with a case-insensitve regular expression.
JDubya is offline  
Old 10-11-2010, 10:43:28 PM     #3 (permalink)

 
pbryd's Avatar
 
Join Date: Mar 2007
Location: Newcastle
Posts: 348
pbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond repute

Thanks JDubya

I haven't tried that yet but I did solve the problem

Instead of the javascript checker checking for lower and upper case I simply converted any uppercase to lower first in the html form on the page.

I used...

Code:
onChange="javascript:this.value=this.value.toLowerCase();"
pbryd is offline  
Old 12-11-2010, 09:07:46 AM     #4 (permalink)

 
pbryd's Avatar
 
Join Date: Mar 2007
Location: Newcastle
Posts: 348
pbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond reputepbryd has a reputation beyond repute

Quote:
Originally Posted by JDubya View Post
PHP Code:
if (form.answer.value != "brabantia" && form.answer.value != "Brabantia") {    
    
alert"oops! try again?" );
    
form.answer.focus();    
    return 
false ;
  }
  return 
true ;

Thanks for this it works fine.

Another bit of useful code snippet to add to my library.

Cheers
pbryd is offline  
Closed Thread



Bookmarks

Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Domain Name Community Replies Last Post
Dynamic form generator/script? wb General Board 2 12-04-2010 11:03:58 PM
Domain Name Industry Reality Check! Domain Valuations, Domain ... - Domain informer RSS Domain Name News 0 21-01-2009 10:59:24 AM
How Famous is your Domain? Free Online Domain Check Tool - Pressemeldungen.at (Presse RSS Domain Name News 0 20-10-2008 07:59:06 PM
Contact Form Help DB Website Design 2 26-11-2006 02:43:52 PM

Domain Sponsor 2


All times are GMT. The time now is 12:43:32 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0 RC 2
All content on Acorn Domains is member generated and is not moderated before posting. All content is viewed and used by you at your own risk and AD does not warrant the accuracy or reliability of any of the information. The views expressed are those of the individual contributors and not necessarily those of AD. Please contact us to report any issues or send a PM to "Admin".