473,386 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

banning certain characcter from javascript validation

114 100+
This is a javascript validation funcction.

i want to add a statement that bans the " character. Could someone help me? Thanks in advance,


Expand|Select|Wrap|Line Numbers
  1.  if (String(frm3.subject.value).replace(/ /g, "") == "")  {
  2.             alert("Please enter subject.")
  3.             document.frm3.subject.focus() ;                
  4.         return false; 
  5.     }
May 7 '07 #1
3 936
pbmods
5,821 Expert 4TB
One minor change, and you're set:
Expand|Select|Wrap|Line Numbers
  1.  if ((frm3.subject.value = String(frm3.subject.value).replace(/"/g, "")) == "")  {
  2.             alert("Please enter subject.")
  3.             document.frm3.subject.focus() ;                
  4.         return false; 
  5.     }
Alternatively, you could just use:

Expand|Select|Wrap|Line Numbers
  1.  if (! (frm3.subject.value = String(frm3.subject.value).replace(/"/g, "")))  {
  2.             alert("Please enter subject.")
  3.             document.frm3.subject.focus() ;                
  4.         return false; 
  5.     }
May 7 '07 #2
karen987
114 100+
Hi thanks pbmods

sorry i wasn't clear,

the statement above removes the " character, what i want is for an alert to say

"sorry you can't use the " character" i don't want to strip it.

thanks a bunch.
May 8 '07 #3
acoder
16,027 Expert Mod 8TB
Hi thanks pbmods

sorry i wasn't clear,

the statement above removes the " character, what i want is for an alert to say

"sorry you can't use the " character" i don't want to strip it.

thanks a bunch.
Use the match method instead of replace. See this link.
May 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
9
by: tzigone | last post by:
hello, i use asp.net validation controls in my site. i wonder whether usin javascript validation will fasten page load speed? there are currently lots of requiredfieldvalidator now is it better t...
111
by: Retlak | last post by:
The recommended (on dozens of websites) and effective (works in Netscape, MSIE, Mozilla, probably others) way to detect if a browser has Javascript turned off is to put this in the <head>: ...
2
by: GIMME | last post by:
Background ... I've created a web application that allows a user to create an HTML application from IE. The application itself creates an XML representation of a XHTML form. The XHTML...
8
by: SAN CAZIANO | last post by:
i have to do in the onkeypress or in onchange the float (real) field validation I try something: function ValidaCampo(nomeCampo,TotInteri,TotDecimali) {...
2
by: Nick Bell | last post by:
I have a general form validation question. I know very little about javascript, a little more about PHP. Using yav (http://yav.sourceforge.net): <form method="POST" name=edit onsubmit="return...
3
by: Mike Collins | last post by:
If possible, how can I use a custom validator to check (client side) that if a certain value was checked in a checkboxlist? So, if they checked "great" or "good", comments are not required and if...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
5
by: Peter Afonin | last post by:
Hello, I'm not an expert in Javascript, so I'm seeking an advice. As I mentioned in my previous post, I use Javascript to check whether at least one checkbox in the datagrid has been checked....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.