Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

What should be proper validations for text fields like country, State, city i.e. can it be only characters or alphanumeric or can it also include special characters

share|improve this question
1  
I don't think there is one single answer to this question; the appropriate validation depends on your application, what kind of data it can work with and is willing to accept. In any case, I don't think this is really a question about testing is it? –  vincebowdren Jun 4 at 10:55
1  
@vincebowdren - it also depends on where you are and the kind of application. The application I work with uses dropdowns pulled from a database for countries and US states. Many web applications use a dropdown to select country, then a second one for state if applicable. –  Kate Paulk Jun 4 at 11:01
    
If this is a true text field, then there is an abundance of test approaches on the web that you can research. Remember that you are trying to show it is broken, so how it reacts to invalid data (including special characters) is definitely something to explore. –  Jeff_Lucas Jun 4 at 16:05

6 Answers 6

It really depends on your project. I'll try to give you some hints, but it can't be comprehensive.

Localization

First thing to take into account is the localization. If your fields can be used by a customer from any country, you must consider allowing non alphanumeric characters, and therefore test it. This can lead to some issues, depending on the type of your application (e.g. breaking HMI). If it should not allow non-ASCII characters, you should start with that. Try Japanese or Arabic and see what happens.

Application type

The type of your application is the second thing i would take into account. If you are on a web application, you'll probably care about special characters, as they can be used in Regular Expressions. It can be the source of many issues if it is not correctly handled by the code.

If your application implies some memory management (e.g. embedded development), the size of the fields will probably be important to test. This can overlap with localization tests, as non ASCII characters can take more space.

Functional constraints

The constraints of your application should naturally imply all limitations for your fields. Does the company only send products to the US? Are some fields created with values from a database (e.g. Country)? Is there a norm for your field (e.g. IP address)?

Monkey Testing

These tests should be done on any fields, as they don't require much time or functional comprehension. Just try typing as many characters as you can and see what happens. I have already seen HMI broken because of no character limit on a textfield. Copying and pasting a very long Lorem Ipsum can lead to interesting things too.

As i said in the introduction, this is in no way comprehensive. Your question, as i understand it, is about the complete work of testing and can't be answered in a few lines. You should find many questions and answers for your problem with Google. I can only invite you to read these as much as you can and create your own testing process for your specific application.

share|improve this answer

At least, it should be alphanumeric, plus ',', '.', '-', '#', '/' (e.g. "Washington, D.C", or "New-York"). Possibly there could be more special characters, and in some cases it could allow hieroglyphs. The most accurate answer for your question should be in specification of the product you test. And if there is none, try asking managers or developers, which characters should be allowed and which shouldn't.

share|improve this answer

It should be depends on your application, in your application country field should be dropdown values means system has to filter state based on country which user selected. Else country should be text field means it should accept character, some special characters etc

share|improve this answer

It should allow some specific special characters which are used in Country/state names. According to me, best option would be providing values in a drop-down, so that user can select desired value from the drop-down and you can put a generic validation message like "Country is required."

share|improve this answer

So I will try and put an extensive answer to this. The first issue is that this is a text box where an end user can insert data as they please.

Boundary Testing

Start with boundary testing, by this I mean find from the business what should be allowed and what shouldn't be allowed. Test at the boundaries of what should be allowed and what should not be allowed. IE, if it's a 10 character limit, attempt with 11 and make sure that it fails.

Special Characters

Next step would be testing with special characters to ensure they don't cause issue with the system. I have experienced situations where textboxes used regular expression and any regular expression in the text box would be processed. This could be a major problem. There is several other issues where special characters can cause problems. This includes things like SQL Injection and Illegal Characters.

After all of that, make sure that it actually works and does what it is supposed to. Also, do things like UI validation, back end validation, integration testing and all of the basics that you should be aware of.

share|improve this answer

please check this link from w3schools.....

java script validations

thanks Prakash Nanda

share|improve this answer
    
Prakash Nanda, this doesn't answer the question. The original poster is asking what data should be permitted. The link you give discusses how to validate. –  Kate Paulk Jul 15 at 10:56
    
I'm inclined to agree with Kate. It's not so much the mechanics of validation at stake here, but rather by what metrics should the validation be performed on. –  corsiKa Jul 15 at 16:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.