This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

taking only numbers and decimals as input

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I am new in this field of programming field and am stuck in this simple problem. I have made a simple form with the function to take input as numbers only. however, it only takes positive numbers as input but does not cater negative values. I have used the function from one of the posts. Also I need to use the data input by user as the input value in another function query () but do not have idea about how to do it. If someone could help me in this matter, please help. Thanking you in advance..

<html>
<head>
<script>
function query() {
window.location.assign("http://localhost:8080/geoserver/wfs?VERSION=1.1.0&REQUEST=GetFeature&SERVICE=WFS&TYPENAME=tasmania_state_boundaries&crs=EPSG:4326&BBOX=UX.val,UY.val,LX.val,LY.val")
}
</script>
</head>
<body>
<script>
function validate(evt) {
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode( key );
var regex = /[0-9]|\./;
if( !regex.test(key) ) {
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}
</script>
<p> Bounding Box </p>
<form>
Upper Left X Co-ordinate: <input type="text" onkeypress="validate(event)" name="UX"/>
Upper Left Y Co-ordinate: <input type="text" onkeypress="validate(event)" name="UY"><br/>
Lower Right X Co-ordinate: <input type="text" onkeypress="validate(event)" name="LX">
Lower Right Y Co-ordinate: <input type="text" onkeypress="validate(event)" name="LY"><br/>
<input type="button" name="Query" value="Query" onclick="query()">
</form>
</html>
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Punit,

please replace with . and it will take negative values also.

Happy Coding :-)
 
Punit Shrestha
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you...
 
Rakesh Keerthi
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are welcome. please close this by clicking solved.
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!