<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fshabeebk.com%2Fblog%2Fhow-to-add-integer-only-in-a-text-field-using-jquery%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:85px; height:21px;"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://shabeebk.com/blog/how-to-add-integer-only-in-a-text-field-using-jquery/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://shabeebk.com/blog/how-to-add-integer-only-in-a-text-field-using-jquery/"  data-text="How to add integer only in a text field using jquery" data-count="horizontal"></a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://shabeebk.com/blog/how-to-add-integer-only-in-a-text-field-using-jquery/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://shabeebk.com/blog/how-to-add-integer-only-in-a-text-field-using-jquery/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>{"id":150,"date":"2014-12-09T12:22:24","date_gmt":"2014-12-09T12:22:24","guid":{"rendered":"http:\/\/shabeebk.com\/blog\/?p=150"},"modified":"2014-12-24T20:29:15","modified_gmt":"2014-12-24T20:29:15","slug":"how-to-add-integer-only-in-a-text-field-using-jquery","status":"publish","type":"post","link":"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/","title":{"rendered":"How to add integer only in a text field using jquery"},"content":{"rendered":"<p><br \/>\nTo allow integer only in text field we can use the following jquery function .<br \/>\nWe can write below code inside a document.ready function and give the class   &#8220;integer-allowed&#8221; for the text box we needed.<\/p>\n<pre class=\"whitespace-before:2 whitespace-after:2 lang:default decode:true \" >\r\n\r\n $('.integer-allowed').keyup(function () {\r\n                            this.value = this.value.replace(\/[^0-9\\.]\/g, '');\r\n                            }); <\/pre>\n<p>\nWorking demo <\/p>\n<p><script src=\"\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.11.1\/jquery.min.js\"><\/script><br \/>\n <script  type=\"text\/javascript\">\n$(document).ready(function() {\n   $('.integer-allowed').keyup(function () {\n          this.value = this.value.replace(\/[^0-9\\.]\/g, '');\n       });\n});\n<\/script><\/p>\n<p><strong>Enter value (Numbers only allowed)<\/strong><br \/>\n<input type=\"text\" class=\"integer-allowed\" name=\"demoname\" \/><\/p>\n<p><input type=\"submit\" class=\"\" name=\"demosubmit\" \/><\/p>\n<p>Working code <\/p>\n<pre class=\"whitespace-before:2 whitespace-after:2 lang:default decode:true \" >&lt;script src=\"\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.11.1\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n &lt;script  type=\"text\/javascript\"&gt;\r\n$(document).ready(function() {\r\n   $('.integer-allowed').keyup(function () {\r\n          this.value = this.value.replace(\/[^0-9\\.]\/g, '');\r\n       });\r\n});\r\n&lt;\/script&gt;\r\n\r\n\r\n&lt;strong&gt;Enter value (Numbers only allowed)&lt;\/strong&gt;&lt;br \/&gt;\r\n&lt;input type=\"text\" class=\"integer-allowed\" name=\"demoname\" \/&gt;&lt;br \/&gt;\r\n&lt;input type=\"submit\" class=\"\" name=\"demosubmit\" \/&gt;<\/pre>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"150\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,533&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>To allow integer only in text field we can use the following jquery function . We can write below code inside a document.ready function and give the class &#8220;integer-allowed&#8221; for the text box we needed. $(&#8216;.integer-allowed&#8217;).keyup(function () { this.value = this.value.replace(\/[^0-9\\.]\/g, &#8221;); }); Working demo Enter value (Numbers only allowed) Working code &lt;script src=&#8221;\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.11.1\/jquery.min.js&#8221;&gt;&lt;\/script&gt; &lt;script [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"150\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;3,533&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[4,14,1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.4.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to add integer only in a text field using jquery<\/title>\n<meta name=\"description\" content=\"How to add integer only in a text field using jquery, let us make a function using jquery and Regular expression\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to add integer only in a text field using jquery\" \/>\n<meta property=\"og:description\" content=\"How to add integer only in a text field using jquery, let us make a function using jquery and Regular expression\" \/>\n<meta property=\"og:url\" content=\"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/\" \/>\n<meta property=\"og:site_name\" content=\"shabeeb Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-09T12:22:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-12-24T20:29:15+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"shabeeb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/shabeebk.com\/blog\/#website\",\"url\":\"http:\/\/shabeebk.com\/blog\/\",\"name\":\"shabeeb Blog\",\"description\":\"A developer blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/shabeebk.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/#webpage\",\"url\":\"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/\",\"name\":\"How to add integer only in a text field using jquery\",\"isPartOf\":{\"@id\":\"http:\/\/shabeebk.com\/blog\/#website\"},\"datePublished\":\"2014-12-09T12:22:24+00:00\",\"dateModified\":\"2014-12-24T20:29:15+00:00\",\"author\":{\"@id\":\"http:\/\/shabeebk.com\/blog\/#\/schema\/person\/71832abe654179971635c65c09bceb29\"},\"description\":\"How to add integer only in a text field using jquery, let us make a function using jquery and Regular expression\",\"breadcrumb\":{\"@id\":\"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/shabeebk.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to add integer only in a text field using jquery\"}]},{\"@type\":\"Person\",\"@id\":\"http:\/\/shabeebk.com\/blog\/#\/schema\/person\/71832abe654179971635c65c09bceb29\",\"name\":\"shabeeb\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/shabeebk.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/0.gravatar.com\/avatar\/9998389cc76a77663881c48f7d4cbba0?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/0.gravatar.com\/avatar\/9998389cc76a77663881c48f7d4cbba0?s=96&d=mm&r=g\",\"caption\":\"shabeeb\"},\"description\":\"Developer,Entrepreneur, software engineer more than that a human being\",\"sameAs\":[\"http:\/\/shabeebk.com\/blog\"],\"url\":\"http:\/\/shabeebk.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to add integer only in a text field using jquery","description":"How to add integer only in a text field using jquery, let us make a function using jquery and Regular expression","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/","og_locale":"en_US","og_type":"article","og_title":"How to add integer only in a text field using jquery","og_description":"How to add integer only in a text field using jquery, let us make a function using jquery and Regular expression","og_url":"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/","og_site_name":"shabeeb Blog","article_published_time":"2014-12-09T12:22:24+00:00","article_modified_time":"2014-12-24T20:29:15+00:00","twitter_misc":{"Written by":"shabeeb","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/shabeebk.com\/blog\/#website","url":"http:\/\/shabeebk.com\/blog\/","name":"shabeeb Blog","description":"A developer blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/shabeebk.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/#webpage","url":"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/","name":"How to add integer only in a text field using jquery","isPartOf":{"@id":"http:\/\/shabeebk.com\/blog\/#website"},"datePublished":"2014-12-09T12:22:24+00:00","dateModified":"2014-12-24T20:29:15+00:00","author":{"@id":"http:\/\/shabeebk.com\/blog\/#\/schema\/person\/71832abe654179971635c65c09bceb29"},"description":"How to add integer only in a text field using jquery, let us make a function using jquery and Regular expression","breadcrumb":{"@id":"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/shabeebk.com\/blog\/how-to-add-integer-only-in-a-text-field-using-jquery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/shabeebk.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to add integer only in a text field using jquery"}]},{"@type":"Person","@id":"http:\/\/shabeebk.com\/blog\/#\/schema\/person\/71832abe654179971635c65c09bceb29","name":"shabeeb","image":{"@type":"ImageObject","@id":"http:\/\/shabeebk.com\/blog\/#personlogo","inLanguage":"en-US","url":"http:\/\/0.gravatar.com\/avatar\/9998389cc76a77663881c48f7d4cbba0?s=96&d=mm&r=g","contentUrl":"http:\/\/0.gravatar.com\/avatar\/9998389cc76a77663881c48f7d4cbba0?s=96&d=mm&r=g","caption":"shabeeb"},"description":"Developer,Entrepreneur, software engineer more than that a human being","sameAs":["http:\/\/shabeebk.com\/blog"],"url":"http:\/\/shabeebk.com\/blog\/author\/admin\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/posts\/150"}],"collection":[{"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":4,"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":278,"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/posts\/150\/revisions\/278"}],"wp:attachment":[{"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shabeebk.com\/blog\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}