RegularExpression Validation
-
Hello Everybody, 1.I have an application where I want to restrict user to enter Blank/White space when they change their password.Can anyone give me the regex which prevent Blank/White space entry. 2. In a gridview I have a textbox which get it's value from a calendar I want that the textbox should not be editable, and it only get value from the calendar. 3.I face a problem in Sql Query. I have an application where user can change his/her address. It gives sql exception when a user enter the address value containing "'s" example Ram's House. Can anyone tell me how to handle this issue. SqlCommand MyComm = new SqlCommand("Insert into ADDRESS_Table (ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4) values ('" + txtAddress1.Text.ToUpper() + "' , '" + txtAddress2.Text.ToUpper() + "' , '" + txtAddress3.Text.ToUpper() + "' , '" + txtAddress4.Text.ToUpper() + "')", this.MyCon); SqlDataReader MyReader = MyComm.ExecuteReader(); MyReader.Close(); MyComm.Dispose(); If anyone have the solution plz help me. Have a nice day... Happy Coding
A key to every Solution
-
Hello Everybody, 1.I have an application where I want to restrict user to enter Blank/White space when they change their password.Can anyone give me the regex which prevent Blank/White space entry. 2. In a gridview I have a textbox which get it's value from a calendar I want that the textbox should not be editable, and it only get value from the calendar. 3.I face a problem in Sql Query. I have an application where user can change his/her address. It gives sql exception when a user enter the address value containing "'s" example Ram's House. Can anyone tell me how to handle this issue. SqlCommand MyComm = new SqlCommand("Insert into ADDRESS_Table (ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4) values ('" + txtAddress1.Text.ToUpper() + "' , '" + txtAddress2.Text.ToUpper() + "' , '" + txtAddress3.Text.ToUpper() + "' , '" + txtAddress4.Text.ToUpper() + "')", this.MyCon); SqlDataReader MyReader = MyComm.ExecuteReader(); MyReader.Close(); MyComm.Dispose(); If anyone have the solution plz help me. Have a nice day... Happy Coding
A key to every Solution
1 - ^\s, I guess. But that doesn't prevent entry, it shows a message. You use jscript to prevent keypresses 2 - Then set it to be disabled, and only enable it when you change the value 3 - your code is a disaster, you should read up on SQL injection attacks. Fixing your code so it's safe will also fix the issue you're having.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
1 - ^\s, I guess. But that doesn't prevent entry, it shows a message. You use jscript to prevent keypresses 2 - Then set it to be disabled, and only enable it when you change the value 3 - your code is a disaster, you should read up on SQL injection attacks. Fixing your code so it's safe will also fix the issue you're having.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Hi, Thanks for your reply. I am new to web development. I want to stop user to entering white spaces. I used your regex but it display the error message if user enter any values other than white space . I need the regex which is opposite to it. 2. My calendar is a JavaScript calendar..can u tell me how to enable it. I disabled the textbox at the declaration time like if (!document.layers) { document.write("<img src="cal1.gif" onclick="popUpCalendar(this, Form1.strDate, "> \"dd/mm/yyyy\")' height=17 width=18> ") } </img> 3. can u suggest me something on SQL Injection so that i can resolve my issues. Happy Coding
A key to every Solution
-
Hi, Thanks for your reply. I am new to web development. I want to stop user to entering white spaces. I used your regex but it display the error message if user enter any values other than white space . I need the regex which is opposite to it. 2. My calendar is a JavaScript calendar..can u tell me how to enable it. I disabled the textbox at the declaration time like if (!document.layers) { document.write("<img src="cal1.gif" onclick="popUpCalendar(this, Form1.strDate, "> \"dd/mm/yyyy\")' height=17 width=18> ") } </img> 3. can u suggest me something on SQL Injection so that i can resolve my issues. Happy Coding
A key to every Solution
AS@13 wrote:
I want to stop user to entering white spaces. I used your regex but it display the error message if user enter any values other than white space . I need the regex which is opposite to it.
^[^\s]*$
this won't match text with spaces or line breaks.
AS@13 wrote:
can u suggest me something on SQL Injection so that i can resolve my issues.
You should use parameterized queries or stored procedures to avoid them. Do a search for SQL Injection attack in CP - You will find useful articles.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
Hi, Thanks for your reply. I am new to web development. I want to stop user to entering white spaces. I used your regex but it display the error message if user enter any values other than white space . I need the regex which is opposite to it. 2. My calendar is a JavaScript calendar..can u tell me how to enable it. I disabled the textbox at the declaration time like if (!document.layers) { document.write("<img src="cal1.gif" onclick="popUpCalendar(this, Form1.strDate, "> \"dd/mm/yyyy\")' height=17 width=18> ") } </img> 3. can u suggest me something on SQL Injection so that i can resolve my issues. Happy Coding
A key to every Solution
AS@13 wrote:
I am new to web development.
*grin* really ?
AS@13 wrote:
I want to stop user to entering white spaces. I used your regex but it display the error message if user enter any values other than white space . I need the regex which is opposite to it.
Then try \s, I guess. ^ means not. Perhaps \S is whitespace and \s is not whitespace. 2 - you need to write javascript to enable the textbox, set the value and disable it again 3 - yes, if you want to be a programmer, I suggest learning how to use google and other search tools. There is at least one excellent article on this site on SQL injection, just type SQL injection into the search box.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
AS@13 wrote:
I am new to web development.
*grin* really ?
AS@13 wrote:
I want to stop user to entering white spaces. I used your regex but it display the error message if user enter any values other than white space . I need the regex which is opposite to it.
Then try \s, I guess. ^ means not. Perhaps \S is whitespace and \s is not whitespace. 2 - you need to write javascript to enable the textbox, set the value and disable it again 3 - yes, if you want to be a programmer, I suggest learning how to use google and other search tools. There is at least one excellent article on this site on SQL injection, just type SQL injection into the search box.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Christian Graus wrote:
Then try \s, I guess. ^ means not
Yes. But
^\s
will assert the position at starting, AFAIK. "not" would be[^\s]
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions