Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
As per my requirement i need to allow hypen and dot including integers only. I have tried in jquery it is working. But i want in server side validation also. Same Jquery code is not working.Please give me solution .Please check my below code in jquery.

C#
$('.vision').blur(function () {
           var tobeMatchedwith = /^[+-]?\d{1,3}([.]\d{1,3})?$/;
           var value = $(this).val();
           if (value.match(tobeMatchedwith)) {

           }
           else {
               showStickyWarningToast('Please enter numerics or numerics with . or - only');
           }
           return false;
       });


i need to allow like this ex: 0.01 ,-0.12 etc.
Thanks

Hari
Posted
Updated 10-Mar-14 19:16pm
v2

string s = number.ToString("N2");
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 11-Mar-14 1:26am    
Hi Arun,
It will accept -(Hypen) and .(dot) also?
ArunAmalraj 11-Mar-14 1:29am    
Am not sure that will do hyphens.

Please check http://www.cheat-sheets.org/saved-copy/msnet-formatting-strings.pdf

Might help you.
//Allows only one '.' inside the textbox
$('#textBoxName').keypress(function (e) {

var keyCode = e.which; // Capture the event

if (e.which != 8 && e.which != 0 && e.which != 46 && e.which != 45 && (e.which < 48 || e.which > 57)) { e.preventDefault(); }

if ($(this).val().indexOf('.') > -1) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { return false } }


});
 
Share this answer
 
Comments
Hari Krishna Prasad Inakoti 11-Mar-14 4:51am    
Hi Swarup,
I want solution for server side not in client side .

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900