[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

multiple text box validation for int only onblur or mouse out...

Posted on 2005-04-08
11
Medium Priority
?
430 Views
Last Modified: 2012-08-14
hello Experts,
I have one form with many checkbox.
I would like to have javascript when mouse is moved out from that field or onblur ( which ever is correct you think) ... I want to validate that if that is int only...
if not alert 'pls enter int' how can I do that.
Regards,
---Pinal
0
Comment
Question by:pinaldave
  • 5
  • 5
11 Comments
 
LVL 25

Expert Comment

by:archrajan
ID: 13738682
onblur = "if(isNaN(this.value)){alert('Please enter numbers');this.select;this.focus();}"
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 13738710
<input onchange="if (/\D/.test(this.value)){alert('integers only please');this.focus()}" onblur="this.onchange()">
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 13738727
this is better

<input onchange="if (/\D/.test(this.value)){alert('integers only please');this.focus()}">
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Author Comment

by:pinaldave
ID: 13738774
Gwyn and Arch
Both works. Thank you very much.

<input onchange="if (/\D/.test(this.value)){alert('integers only please');this.focus()}"> how can I have focus back to the field which has the not an integer.
Thank you. It is moving the focus to where ever I have clicked. It should not let me enter any thing else than integer... cause it is moving the focus from that field and I can still submit it and my application is crashing.. somehow due to some complexity I am not able to use server side validation.

Regards,
---Pinal
0
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 2000 total points
ID: 13738783
Then again it depends on how you want this, using the onblur may be bettrer for this. I am assuming you want just integers, ie 3.142 is not allowed.

<input onblur="if (/\D/.test(this.value)){alert('integers only please');this.focus()}">
0
 
LVL 21

Author Comment

by:pinaldave
ID: 13738800
Arch Just tried your solution again...
it does not work.. thank you both of you for helping me... all the time...
I still need help.
Regards,
---Pinal
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 13738815
I think the above does it.
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 13738826
Thx for the points. :-)
0
 
LVL 21

Author Comment

by:pinaldave
ID: 13738827
<input onblur="if (/\D/.test(this.value)){alert('integers only please');this.focus()}">
works and good suggestion.
No.. I do not want float Just an integer...was working on server side validation for more than one hour.. this will do the same job...
Regards,
---Pinal
0
 
LVL 21

Author Comment

by:pinaldave
ID: 13738846
Look out for another Q which I will post in a min... pls...
Thank you.
---Pinal
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question