473,386 Members | 1,748 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.

Need to throw an alert when enetering special characters in JavaScript

I need to throw an alert saying "Enetered special characters " alert when i click on submit button in javascript. Need code for this

Please help!!!!!
Oct 4 '09 #1
5 2750
i used the below code. But it is not working. Please help as i need to finish it off.

Expand|Select|Wrap|Line Numbers
  1. if(validate(document.loginForm))
  2. {
  3. username=document.loginForm.value;
  4. document.loginForm.value=username;
  5. if (username.indexOf("%") != -1) {
  6. alert ("The box has special characters. \nThese are not allowed.\n");
  7. }
  8. passwd=document.loginForm.passwd.value;
  9. document.loginForm.passwd.value=passwd;
  10. document.loginForm.action="login.do";
  11. document.loginForm.submit();
  12. }
  13. }
Oct 4 '09 #2
Dormilich
8,658 Expert Mod 8TB
the code snippet does not make much sense
- there’s an unopened code block (closing curly bracket)
- there’s an undefined function (validate())
- there’s no definition of "special character"
- lines 4/8/9 seem unnecessary
Oct 4 '09 #3
I didn't post entire code. I have a text box called username.
If user is enetering sepecial character like % it should throw an alert.
This is my requirement.

Appreciate your help !!!!!!
Oct 4 '09 #4
Dormilich
8,658 Expert Mod 8TB
ok, test #1: do you actually enter this code block?
Oct 4 '09 #5
Hey iam able to do this.
Thanks for the response...!
Oct 5 '09 #6

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

Similar topics

5
by: Arjen | last post by:
Hi All, What I want to is using a string as PATTERN in a split function. This makes it possible for me to change the PATTERN on one place in my script... For example: $separator = ";"; $line...
9
by: CW | last post by:
I wrote an HTML based chat application. The front end is built entirely on HTML + javascript. Essentially, I have a hidden frame that's refreshed frequently and any new messages are displayed in...
7
by: Daniel | last post by:
I`m trying to show japanese characters in an alert, like; alert('実装されていませ'); This doesn't work as shown in this post:...
3
by: Renato Vieira | last post by:
When i use special characters in a javascript alert() like 'ç' or 'Ă£', the message is displayed white a blank square. How can i avoid this? thanks in advance. -- Renato /*Portugal*/ Vieira
10
by: Peter Michaux | last post by:
Hi, Today I have been testing the event models from Netscape 4.8 and IE 4 to the current crop of browsers. I'd like to write a small event library similar in purpose to the Yahoo! UI event...
2
by: helraizer1 | last post by:
Hi folks, I have this site and idea http://www.helraizer.co.uk/mychatbox/ at the moment I'm using javascript to alert the user if they haven't entered a username or message but all this does is...
7
by: proximus | last post by:
hello i need some modal dialog box to show when page is loaded any sugestion? not 'onclik' thanks -- www.proximus-os.hr ; www.e-stranica.com ; www.zlatovezi.com
1
by: saravanatmm | last post by:
I need javascript code for validate the email address. Email address field cannot allowed the capital letters, special characters except '@' symbol. But can allowed the small letters, numeric...
3
by: teser3 | last post by:
I have the below that limits the textarea input to 500 characters but cant get the alert message to work. It doesnt show anything. Please advise. <script language="javascript"...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.