By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,584 Members | 1,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,584 IT Pros & Developers. It's quick & easy.

submit button isnt working

P: 4
am doing my first project so plz help
i've created a submit button
[HTML]<input type="submit" onclick="valid()">[/HTML]
my function valid checks if the fields are not empty if empty a window prmpt appears then when i press ok i move to the next page
for example
[HTML]<script type="text/javascript">
<!--
function valid()
{
var n=document.form.fname.value.length;
if(n==0){
window.alert("enter ur first name");
return false;
} }
//--></script>
[/HTML]then the php code
[HTML] <input type="submit" name="sub" value="Submit Your Entries" onclick="valid()" />
[/HTML]i wrote instead of type="submit" =>type="button" it works but when i fill all the fields am not moving to next page
Oct 5 '07 #1
Share this Question
Share on Google+
5 Replies


FullyH3ktik
P: 52
what if you added this to your function:
Expand|Select|Wrap|Line Numbers
  1. else
  2. {
  3. location.href="URL goes here";
  4. }
that way if the field is not blank, it will take you to the page specified.
Oct 5 '07 #2

100+
P: 283
<input type="submit" onclick="valid()">
<script type="text/javascript">
<!--
function valid()
{
var n=document.form.fname.value.length;
if(n==0){
window.alert("enter ur first name");
return false;
} }
//--></script>
hi soheir,
why are you using <!-- --> ? you are commenting the function that needs to be called...plz remove the comments...
regards,
ajos
Oct 5 '07 #3

dmjpro
100+
P: 2,476
am doing my first project so plz help
i've created a submit button
<input type="submit" onclick="valid()">
my function valid checks if the fields are not empty if empty a window prmpt appears then when i press ok i move to the next page
for example
<script type="text/javascript">
<!--
function valid()
{
var n=document.form.fname.value.length;
if(n==0){
window.alert("enter ur first name");
return false;
} }
//--></script>
then the php code
<input type="submit" name="sub" value="Submit Your Entries" onclick="valid()" />
i wrote instead of type="submit" =>type="button" it works but when i fill all the fields am not moving to next page

Use code Tags buddy :-)
Please read the posting guidelines before you post.

Have a look at this ....

Expand|Select|Wrap|Line Numbers
  1. <form onsubmit = "return valid();">
  2. .
  3. .
  4. </form>
  5.  
Expand|Select|Wrap|Line Numbers
  1. function valid()
  2. {
  3.  return (condition_satisfies);
  4. }
  5.  
Debasis Jana
Oct 5 '07 #4

pbmods
Expert 5K+
P: 5,821
Heya, ajos.

why are you using <!-- --> ? you are commenting the function that needs to be called...plz remove the comments...
The code is not actually commented. It's an old trick to prevent *really* older browsers (does anyone use a browser that doesn't know what JavaScript is anymore?) from displaying JavaScript code on the web page. But all modern browsers know that the code isn't *really* commented.

Nowadays, the bigger concern is XML compatibility. That's why you often see:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. // ]]>
  4. </script>
  5.  
Oct 5 '07 #5

100+
P: 283
Heya, ajos.
The code is not actually commented. It's an old trick to prevent *really* older browsers (does anyone use a browser that doesn't know what JavaScript is anymore?) from displaying JavaScript code on the web page. But all modern browsers know that the code isn't *really* commented.

Nowadays, the bigger concern is XML compatibility. That's why you often see:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. // <![CDATA[
  3. // ]]>
  4. </script>
  5.  
hey pbmods,
thanks for correcting me regarding this, i got stumped by seeing <!-- --> this in the first place(not common to see actually).:-)
this forum is great...keep up the good work friends!!!
regards,
ajos
Oct 5 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.