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

how to check given input integer or not

I can take (id-Integer in model class) input from spring form ,how to check whether integer or not
output -suppose I gave input integer format con't show any error , but gave string format it can show error
Failed to convert property value of type java.lang.String to required type java.lang.Integer for property id; nested exception is java.lang.NumberFormatException: For input string: "dfgrgf"
Employee id required or Employee Id greater than 0
Nov 4 '16 #1
1 1316
chaarmann
785 Expert 512MB
You can check with regular expressions if the string conforms to "\d+". If it does, then it is an integer.
But you need to tell us more. Do you also need to check for negative integers?
Is the integer length limited to10 chars?
Do you need to trim white spaces before/after the integer away?
If all yes, you can check with the regEx "\s*[+-]?\d{1,10}\s*".
Nov 7 '16 #2

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

Similar topics

1
by: mr_burns | last post by:
hi, if i have a datebase field like so: $username = $row; //after SELECT and mysql_query etc. how do i check what file type it is? i have tried using is_string to check it but it returns...
1
by: GIMME | last post by:
If I have : <input name="a1" value="1"> <input name="a2" value="3"> <input name="a3" value="2"> And I want the user to enter the values 1,2, and 3 but not necessarily in that order .... (The...
4
by: Georg Vassilopulos | last post by:
Hello! How do I check user input for following formats: I only want to accept floats or integers written as: 232,45 232 242.45 345
14
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal =...
8
by: Eps | last post by:
I have a for loop and i want to do different things depending on whether the counter is even or odd. I know there is probably some really simple math thing that can do this but my maths is a bit...
4
by: ija | last post by:
i try to limit the user key in integer at least 1 and not more than 8. pls help me..
3
by: PHPstarter | last post by:
Hiya. I have a script that is run by a <form> which basically allows u to write into inputs the fields username, new username, password, repeat password, comment etc, The problem is that I want...
2
by: Avery Mathews | last post by:
Hi I've just started c programming and I have a task which requires me to check if a certain value i calculated is an integer. I've tried using if (fmod(variable,1)==0){ integer.. }else{ not...
6
by: radha gogia | last post by:
Given an integer ‘K’ and a tree in string format. We have to print the sum of all elements at Kth level from root. 0 / \ ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.