Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

text box on blur validation for empty field

Posted on 2005-04-18
3
Medium Priority
?
282 Views
Last Modified: 2011-09-20
hello,
I am using following script to make sure in the text box that when I leave it ... it allows does not allow anything else than numeric. Numbers are allowed only. Empty string should be allowed but when user leave the text box the empty string should be converted to zero automatically.
How can I do this>>>
When user leaves the text box the empty string is replaced by Zero (0) Digit.
This is what I have >>>
onBlur="if (/\D/.test(this.value)){alert('Please enter the digits only');this.focus()}""
Regards,
0
Comment
Question by:pinaldave
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Colosseo earned 2000 total points
ID: 13810913
Hi

You could change your onBlur to add this

if(this.value==''){this.value=0}

so

onBlur="if (/\D/.test(this.value)){alert('Please enter the digits only');this.focus()};if(this.value==''){this.value=0};"

HTH

Scott
0
 
LVL 21

Author Comment

by:pinaldave
ID: 13810927
Thank you very much for quick and correct answer.
Regards,
---Pinal
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 13810932
Your very welcome, thank you for the grade.

Cheers

Scott
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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

564 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