input-validation

No blanks in JTextField

How can I forbid users to put blanks into a JTextField? It should not even be possible to write blanks. ...

ModelState.AddModelError encodes HTML

Hi I am noticing a weird issue when using ModelState.AddModelError to validate input on my forms. The output from Html.ValidationMessage is not the true HTML value but it's encoded value and so the CSS style is not applied to the error message. Example: private string errorMessage = "<span class=\"negative\">{0}</span><br class=\"hid\...

Mailing Address Verification, Etc. Get County from Zip

It seems fairly common today for websites to perform some address verification behind the scenes. For example, the 4 digit extension on zip codes is commonly filled in. In addition to filling in the 4 digit zip code extension, I would like to know what county the address belongs to. This will be utilized in an ASP.NET 3.5 application ...

How best to sanitize input in Java webapp

We use jsp, servlets, beans with mysql database. We don't want to restrict the characters entered by users on form fields. So how do I sanitize the input and how to make sure the output is not changed for malicious activities. Is there way while sending the output I could check if extra code has been sent. Like suppose there is search in...

In Swing use an InputVerifier to check dates and time

I'm currently working on a Swing app and I've got a few JTextAreas that are going to be parsed, turned into dates and then added to a MySQL database. One is a Date field, the others are DateTime, what I'm trying to do is use InputVerifier to make sure they're entered correctly. I've created an InputVerifier that tries to turn the text i...

Can this be a efficent and reliable way to purify user's input?

Hi guys, im wondering about how to set up a clever way to have all my input 'clean', a procedure to run at the begin of every my script. I thought to create a class to do that, and then, add a 2 letter prefix in the begin of every input to identify the kind of input, for example: in-mynumber tx-name ph-phone em-email So, at the top of...

Java - Editable ComboBox Validation

I'm looking into the various ways to validate input for an editable JComboBox. Currently, I need to restrict input to numbers in a specified range. Thus far I've found 3 distinct ways. Any thoughts on the best way to approach this? JComboBox comboBox = new JComboBox( new Object[] {"Donnie", "Danny", "Joey", "Jordan", "Jonathan"} ); ...

Automatically sanitize entries on HttpRequestValidationException

The infamous A potentially dangerous Request.Form value was detected from the client question :) Here's my use case: I have a FCKEditor control on a webpage, that allows users to type HTML. That precise webpage has validation turned off to allow its use, but my masterpage has linkbuttons that can raise postbacks on other pages. I obvi...

How can I validate text box input in Visual Basic?

I am doing a program and I need to validate my text boxes. For the program the user needs to put in a phrase. But I am not sure how to make sure that the user actually entered in a phrase, the phrase isn't (ex.) skldkfdl, or that there isn't a space. ...

Custom Zend Error message for checkboxes

I have a form in a Zend-based site which has a required "Terms and Conditions" checkbox. I have set a custom message which says "you must agree with terms and conditions". however, because the checkbox is "presence='required'", it returns Field 'terms' is required by rule 'terms', but the field is missing which is this constant de...

C# Input validation for a Textbox: float

This supposedly easy task gave me some headache. I simply want to let the user enter any text that succeeds float.TryParse into a Textboxish control. I could use a normal TextBox and check the Text in some btnOK_Click, but this is obviously lame. Also, there is a nice built-in MaskedTextBox control, but I failed to set it's mask to be e...

Check whether user input is a valid string or not using C

Hi I am taking a string input from user. But how d I check whether user has entered a string or a number?? ...

Avoiding duplicate code in input validation

Suppose you have a subsystem that does some kind of work. It could be anything. Obviously, at the entry point(s) to this subsystem there will be certain restrictions on the input. Suppose this subsystem is primarily called by a GUI. The subsystem needs to check all the input it recieves to make sure it's valid. We wouldn't want to FireTh...

How to filter out all non-word characters from user input in Java

I'm trying to filter out all possibilities of XSS from user name input while still allowing for foreign names to be inputted. What is the best way to white-list all word-characters in multiple languages (also Chinese and Japanese and Russian)? Is this possible at all? It would be easy to create a blacklist for XSS with "<>&gt;&lt;" but...

How do I match a specific number in javascript?

I have a situation where, in javascript, I need to compare the contents of one string to see if it contains the exact same number in another string that could contain multiple numbers. For example. Source: "1234" Comparison: "1000 12345 112345 1234 2000" It should only match on the 1234 and not on the 12345 or 112345, etc. It also n...

Sanitize a PHP password string

I have a PHP page that allows people to run htpasswd to update their password. What is the best way to sanitize their input. I don't want to restrict the input to much because I want to allow for secure passwords. This is what I have. How can it be improved? $newPasswd = preg_replace('/[^a-z0-9~!()_+=[]{}<>.\\\/?:@#$%^&*]/is', '', $...

How to allow only numeric (0-9) in html inputbox using jQuery?

I am creating a web page where I have a input text field in which I want to allow only numeric characters like (0,1,2,3,4,5...9) 0-9. How can i make it using jquery?? Thanks ...

Javascript String Validation

i have a string... i want to validate that string so that it should not contain certain characters like '/' '\' '&' ';' etc... how can i do that all at once??? ...

Validate field value using another field

Hi, I am trying to validate my model, I am using CakePHP 1.2.3.8166 and mysql 5 I have my model definied as it: class Actividad extends AppModel { var $name = 'Actividad'; var $validate= array('maxfield' => array( 'rule'=> array('chkValue'), 'message'=>'i2' )); function chkValue($data){ return $data["maxfield"]>=$data["minfi...

quiet bot detection and filtering in ASP.NET MVC

I'm setting up an e-mail form for scientific journal articles. I need to be able to check for bots and filter them quietly. The site run ASP.NET MVC. I'd like to avoid CAPTCHA. Any ideas? ...