javascript problem on my page with validations...

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

javascript problem on my page with validations...

Post by djdon11 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello everyone ..

i have a problem ..

i am using javascript validations on my page .. if there is any error on submitting the form fields than this validation shows a warning box which shows the warning with ok button .. the problem is that .. when i press the ok button the page get submitted   and all the false values inserted into the database ...

anybody have any idea what it is going on .... ?/?

[syntax="javascript"]function validation()
{
var error ="\n";
var flag=false;
  	if(document.from1.title.value=="")
	  {
		flag=true;
		error=error +"Please You Must Enter The Subject.\n";
    	}
		if(document.from1.person.value=="")
	  {
		flag=true;
		error=error +"Please Enter The responses.\n";
    	}
		if(document.from1.fees.value=="")
	  {
		flag=true;
		error=error +"Please Enter The Fees.\n";
    	}
		if(flag==true)
		
		{
		alert(error)
		return false;
	   }
	   else
	    {
 		return true;
	}
 }
the above is the code for all validations when this get false then the message shows there but when i press ok the form get submitted which should not submit .....


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
N1gel
Forum Commoner
Posts: 95
Joined: Sun Apr 30, 2006 12:01 pm

Post by N1gel »

Can you show the html where you call the javascript function.

I use javascript to validate a form here is an example of how i call it. you may be missing the return.

Code: Select all

<form id='subform' onSubmit='return ValForm()' method='post' action='$this->pagename?command=process'>
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

Post by djdon11 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


yes i am using the same thing on form .....


see this function 
[syntax="javascript"]
function verify()
{
	var str;
	str=confirm("Are you really want to delete skills ?");
	if(str==true)
	return true;
	else
	return false;
}
and i am calling this function on form submit like this...[/syntax]

Code: Select all

<form name="frm_skill" acion="?do=delete&acion=setskills" method="post" onsubmit=" return verify();">
but my page gets submited.... when i press cancel


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
djdon11
Forum Commoner
Posts: 90
Joined: Wed Jun 20, 2007 5:03 pm

Thanks it is working now

Post by djdon11 »

Hi friend ,,,

it is working now ...

thanks alot ....
Post Reply