Display message without alert..

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Gopesh
Forum Contributor
Posts: 143
Joined: Fri Dec 24, 2010 12:48 am
Location: India

Display message without alert..

Post by Gopesh »

Hai,
i am developing a form in which i want to validate user input,am using onblur event .i want to display a validated message in a div on the same page without using alert.
pls help me to acheive this?
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Display message without alert..

Post by Apollo »

you probably want to adjust the div's innerHTML:

Code: Select all

<html><body><script type='text/javascript'>
function check(f)
{
  document.getElementById('bar').innerHTML = RegExp(/[^0-9]/).test(f.value) ? 'Numbers only please!' : 'OK';
}
</script><form>
<input name='foo' onblur='check(this)'><div id='bar'></div>
</form></body></html>
Gopesh
Forum Contributor
Posts: 143
Joined: Fri Dec 24, 2010 12:48 am
Location: India

Re: Display message without alert..

Post by Gopesh »

thanks Apollo.it works fine,problem is solved..
Post Reply