how do you validate a form soo there is no alerts all i need is image and words to display next to the text box when something incorrect has been typed in

Create a div to next to the text box or any field where you want to display something like.

<div id ="err1" style = "display:none">error message</div>

In validation function

function val()
{
if(error_condition)
{
document.getElementById('err1').style.display = "block";
}
}

Create a div to next to the text box or any field where you want to display something like.

<div id ="err1" style = "display:none">error message</div>

In validation function

function val()
{
if(error_condition)
{
document.getElementById('err1').style.display = "block";
}
}

Thet's fine as far as it goes but you also need to hide error messages after each error is cleared by the user and the form is re-validated.

In addition, it's more typical to use spans (inline elements) rather than divs (block elements), but this will depend on the layout of the form and where you want the error messages to appear.

Adapting Mahavir's notation, we get:

function val(){
  document.getElementById('err_1').style.display = (error_condition_1) ? 'inline' : 'none';
  document.getElementById('err_2').style.display = (error_condition_2) ? 'inline' : 'none';
  document.getElementById('err_3').style.display = (error_condition_3) ? 'inline' : 'none';
}

Airshow

ya i want to validate the dropdown list.. validating without alert box my issue is that if not fill value statement appears(validated), if i fill the value the statement should disappear

Praba11,

Validating a dropwown list (a <select> element presumably) doesn't make any sense. Its value can only ever be that of one of the options offered - all of which should be 100% valid, otherwise something has gone horribly wrong in coding the HTML.

Have a think about what you really want, recompose your question and ask it in a new thread rather than tacking onto an old one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.