Sunday, 15 August 2010

javascript - Allow only number in text box based on consecutive id -


Only numbers here will be allowed.

I want to do this based on ID.

So I created it

  $ (document) .ready (function () {// call when pressed into $ 1 ("# quantity") text box Keypress (function (e) {// if there is no letter number, display the error and do not type anything (E.Jo! = 8 & amp; e.which! = 0 & amp; amp; A. & Lt; 48 || e.which> 57) {// display error message $ ("# errmsg") .html ("only digital") Show (). FadeOut ("slow"); return back; }}};});  

How can I do this for a series of identities like Quantity 1, Quantity 2 ..

Update: < / P>

I can not use the class name. I only assign it to id

All you have to do is find it easy to match all the IDs. See this.

Here is the part code -

  $ (document) .ready (function () {// When the key is pressed into the text box $ ("[id ^ = Quantity] "). Keypress (function (e) {// if there is no letter number, display error and do not type anything (E. Joe !! = 8 & amp; e.wich! = 0 & amp; ; & Amp; Amp; (E.H.I.E.E.T. & LT; 48 || E.H.C.T.> 57)) {// Display error message $ ("# IRMSG ") .html (" points only ") show (). Feedoff (" slow "); the description is false;}}};});  

No comments:

Post a Comment