Welcome visitor
* Login
* Register
It is currently January 22nd, 2019, 6:15 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  validate a form
PostPosted: September 21st, 2009, 8:35 pm 
User avatar

Posts: 44
I want to validate a form before sending it, this is what i have but it sends the form anyway. Can you see what's wrong in it?
<form onsubmit="validate();">
<script>
function validate(){
x=document.getElementById('total').value;
if(x<=49.99){return false;}
else{return true;}}
</script>


Top
 Profile  
 
  Re: validate a form
PostPosted: September 21st, 2009, 9:36 pm 
User avatar

Posts: 81
the return statement should be also on the onsubmit event, like this
<form onsubmit="return validate();">


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron