Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8645565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:34:59+00:00 2026-06-12T12:34:59+00:00

Excuse me if the mistake is very silly, because I am just getting started

  • 0

Excuse me if the mistake is very silly, because I am just getting started with Javascript (and programming in general, by the way, I like it) I am trying to create a small program, and in one of the input fields, you have to write your name. I made a function to prevent that you include characters such as &%$?¿ and so on…

The problem is that the function works fine… sometimes yes, sometimes no… it seems to depend of where exactly you type the non valid characters, but due to my limited understanding of programming, I still cannot understand what am I doing wrong. Here, take a look:

 function validate_input(text) {


    var notgood = "!"·$%&/()=?¿@#¬"; //cannot have this inside name

    var i = 0;   

    while (i <= notgood.length) { 

        if (text.indexOf(notgood.charAt(i)) ==-1) {
            ind = ind + 1;  
            break; 
        }
        else {  
            alert("Your name cannot include symbols");
            var text = prompt("Try again");
        }
    }}

A million thanks. Is just a small detail. I can have my input without checking for symbols, but I feel a bit silly of not being able to understand this problem…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:35:00+00:00Added an answer on June 12, 2026 at 12:35 pm

    You code might work, if you escape the second " in the notgood string:

    var notgood = "!\"·$%&/()=?¿@#¬";
    

    Although I see many other potential issues, like the ind global.

    Or you can try a regexp instead, it’s cleaner for your use case

    var notgood = /[!"·$%&/()=?¿@#¬]/; //cannot have this inside name
    
    if ( notgood.test( text ) ) {
        alert("Your name cannot include symbols");
        text = prompt("Try again");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please excuse me if this is a very simple solution or stupid mistake -
I am a newbie in this field so please excuse my silly mistakes :)
Excuse the 'noob' question, but can someone please explain the way ASP.NET's buttons work.
Excuse if this is more a file format conversion question rather than programming, but
Excuse me first. because i don't know this is question is valid or not.
Excuse me if this is a silly question but i'm a beginer here. I
Excuse me because I am a beginner in Java ... I want to translate
Excuse the rough code, I'm trying to display the duration of videos given the
Excuse my English, I speak Spanish, My question is how could I just click
I am a systems programmer, so i just know some basic css/html. I like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.