473,385 Members | 2,013 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,385 software developers and data experts.

Regular Expression - having issues with empty string

Hi, I have a textbox where I want the user to be able to enter either:

(1). Nothing
(2). up to 3 digits, optional decimal, up to 2 decimals.

I've been using ^\d{0,3}(\.\d{0,2})?$ but it's not allowing the empty string.

Thanks for any help!
Oct 23 '12 #1
5 1565
Rabbit
12,516 Expert Mod 8TB
That expression works fine for me. What does the code look like?
Oct 23 '12 #2
asp.net...

Expand|Select|Wrap|Line Numbers
  1. <...ID="PercentageValidate" Display="Dynamic" ForeColor="Red" runat="server" ControlToValidate="Percentage" ValidationExpression="^\d{0,3}(\.\d{0,2})?$" ErrorMessage="Error!" />
Oct 23 '12 #3
Even using ^(\d{0,3}) gives me issues with an empty textbox
Oct 23 '12 #4
Rabbit
12,516 Expert Mod 8TB
It may have to do with asp.net's specific implementation. But try checking that it's actually a blank string in the control and not a null.
Oct 23 '12 #5
^(?!\s*$).+ try putting this
Oct 26 '12 #6

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

Similar topics

6
by: Matt | last post by:
I want to check if the user enters alphabet or numbers only in the text box. If the user enters non-alphabet or non-numbers, I should pop up a message and doesn't allow the user to do that. I am...
3
by: moondaddy | last post by:
I need to rename file names with a specific naming convention which includes adding a SKU number at the end of the file name and I would like to use a regular expression to do this, but I don't...
2
by: Robin Tucker | last post by:
Hiya, Regular expressions always do my gnads in - can anyone cook up a reg expression to find all string literals in my code? I would like to put them into a resource file for future...
1
by: guozhen | last post by:
hey.I got a problem I want to parse the string below with regular expression ¡°1¡¢¾«Í¨»ùÓÚJ2EE¼Ü¹¹µÄJavaºËÐÄÓï·¨¡¢Java±à³Ì£¬3ÄêÒÔÉÏÈí¼þ¿ª·¢»òÅàѵÏà¹Ø ¹¤×÷¾­ÑéÕߣ»<?xml:namespace prefix = o ns =...
4
by: jpluttme | last post by:
I need to replace not just the ASC or DESC but the value it's sorting by. i.e. in a string like this: http://www.mysite.com/page1.php?value=uservalue1&sort=ORDER+BY+uservalue1+DESC I've not had...
6
by: =?Utf-8?B?QmlsbEF0V29yaw==?= | last post by:
Hi, Thought this would be simple! If I want to validate a field that can contain "z" followed by 3 digits OR it's a completely empty string, how do I do that? The z123 bit is simple, but the empty...
1
by: pnsreee | last post by:
Hi I have following strings Sun:mon:tue mon:tue:wed mon:wed:mon I need to check the string have valid values sun,mon,tue,wed and also check duplicates are there or not
1
by: sreemathy2000 | last post by:
My requirement is to read/write a javascript file in a windows applications. this javascript file is used by my website.. function test { var a; //start dim obj ={'abc','bcd','cde','def'};...
2
by: Gabriela | last post by:
Hi, I need help with writing a regexp that identifies HTML encoded strings. The problem occurred because I have a field in the DB, that contains regular ASCII chars, as well as HTMLencoded...
3
by: akshalika | last post by:
I want regular expression which check for empty. pls help me.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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.