Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 17th, 2004, 01:05 PM
Authorized User
 
Join Date: Feb 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default validation of text box

Hi,
I am trying to validate value put in by customer in the text box. I want to catch if they put in "'" as don't want them enter "'". Is there any built in javascript function that will let me to that. Or I will have to write some function myself.

Thanks

 
Old April 17th, 2004, 02:51 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I think you will have to write a function yourself, such as this:

function validateTextBox(textBox)
{
 if(textBox.value.indexOf("'") != -1 || textBox.value.indexOf("\"") != -1)
 {
  backspace(textBox);
 }
}

function backspace(textBox)
{
 textBox.value = textBox.value.substr(0,textBox.value.length - 1);
}

...

<input type=text onchange=validateTextBox(this)>

Let me know if this helps you.

Snib

<><
 
Old April 18th, 2004, 12:41 PM
Authorized User
 
Join Date: Feb 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your reply, i will try that






Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Multiple emails validation in one text box with co kumiko Javascript 5 February 7th, 2008 05:49 AM
Extract text from text file & put in dropdown box tsukey Beginning PHP 5 July 20th, 2004 09:49 PM
Search using drop down list box and a text box tcasp Classic ASP Basics 1 July 31st, 2003 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.