473,748 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to throw an alert when enetering special characters in JavaScript

19 New Member
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 2767
raagadeepthi
19 New Member
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 Recognized Expert Moderator Expert
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
raagadeepthi
19 New Member
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 Recognized Expert Moderator Expert
ok, test #1: do you actually enter this code block?
Oct 4 '09 #5
raagadeepthi
19 New Member
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
7565
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 = "field1;value1"; local($field, $value) = split(/$separator/, $line);
9
4529
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 another frame using document.write. My problem is that since chat screen can be obscured by other applications/windows, I have no way of informing users that new messages have arrived other than popping the window to the top using window.focus....
7
5744
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: http://groups.google.com/groups?hl=en&lr=&threadm=F2QCa.15007%24Xl.400929%40twister.rdc-kc.rr.com&rnum=2&prev=/groups%3Fq%3Djapanese%2Balert%26hl%3Den%26lr%3D%26group%3Dcomp.lang.javascript%26selm%3DF2QCa.15007%2524Xl.400929%2540twister.rdc-kc.rr.com%26rnum%3D2 This post implyes that it's possible to use the \uXXXX...
3
8226
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
2844
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 library but with less features and code. The Yahoo! event library is one of the best libraries in YUI but it still seems to me to have some confused code...that or I'm still confused. The Yahoo! UI library focuses on using addEventListener and
2
2575
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 popup an alert message and return false. However, if their browser does not support javascript (javascript is turned off) then it just won't send and will give them no reason why. How would I get it so that, using php, if the submit button is...
7
1593
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
3138
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 numbers. Now i use this script for validate the email address. But it allows the cpital letters otherwise its working correctly. SCRIPT FUNCTION ************************************************
3
4204
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" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length limitNum) { limitField.value = limitField.value.substring(0, limitNum); alert("You are trying to enter more than 500 characters"); } else {
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.