Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP Form Validation

Status
Not open for further replies.

danglingpointers

Technical User
Jul 29, 2005
18
US
And now I shall reveal my truly newb-self. I have a form which I want to validate its fields before I submit it to a database. I am having some problems with my javascript.

Code:
function form_validate(thisform)
{
with(thisform){
if(FIELD_VALUE.equals(null)){
alert("Enter a value!");
}
return false;
}};

//elsewhere

<form method=get action=display.jsp onsubmit="return form_validate(this)">

I know the function is being called because I tested this without the "if" clause and the alert box always ran. FIELD_VALUE is the value entered in an <input type="text"> element. However, my "if" statement is returning false even when the element FIELD_VALUE is left blank.

Thanks in advance.

- Tim
 
For JavaScript questions use forum216.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Sorry about that. Can I move the post myself or do I need a moderator to do that for me?
 
You can post it by yourself.

Anyway, it's failing because the text you're receiving is not null, it's just a blank ("").

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top