codetoad.com
Home||ASP|ASP.Net|C++/C#|DHTML|HTML|Java|Javascript|Perl|VB|XML||CodeToadPlus!||Forums||RAM
Search Site:
Search Forums:
Form Field Validation Archive Import (Jeff Krause) at 08:58 on Wednesday, May 22, 2002

I am trying to implement a field validation function:

function validate()
{
var result = true;
var x=document.problem_form.explanation.value;
if ((x==null) || (x.length==0))
{
alert("Please enter an explanation");
result = false;
}
return result;
}


Now if the field is empty, it will display the alert window, but it will also perform the FORM ACTION. I can't figure out why. Is there some special situation that will make it perform the ACTION that I just happen to be in? Any advice would be great.

Thanks,
Jeff Krause




Re: Form Field Validation Archive Import (David) at 15:21 on Wednesday, May 22, 2002

Hi Jeff
You probably need to call the function using return eg.

onsubmit="javascript:return validate()"

that should then pick up the false I think.

Hope that helps
David








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
matrix addition
Re: Storing data from HTML to Excel or TXT
Re: function within loop problem
Re: Ô‡´ò¥¯¥é¥Ö¤Ï ¥Æ©`¥é©`¥á¥¤¥É£ò£±£±¥¢¥¤¥¢¥ó ¤Î£··¬ ¤Ç¤¹
Re: Replace
Re: タイトリスト AP2アイアン 712�情�
Re: SMS from Perl using HTTP request
Re: Charl Schwartzel
Re: Adhyayan - Annual Student Conference and Online Coding Festival


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


Copyright codetoad.com 2001-2013