473,382 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

blank form submits

Hi Guys

It seems i posted this in the incorrect topic, so i am reposting here.

Please excuse the Newbie question. I am not really a programmer so excuse me if i dont clarify my point correctly. I am trying to debug an ex-employee's web code and seem to sinking here. Let me try to explain.

We are receiving few blank submit forms via a handful of clients websites. Ordinarily i would not stress too much as it is less that 5% of the form submits that are failing. However, seeing as we are looking after the clients SEM (search engine marketing) and the clients are getting charged for the submits (in a round about kinda way).I was informed by the miscreant that the blank form submits are due to client machines that do not have java installed or enabled in the browser. Now this does sound plausible to me, but very convenient.

Below is the code i am looking at
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2. function Validation(form){
  3.  
  4. if (form.name.value == ""){
  5. alert("Please enter 'First Name'.");
  6. form.name.focus();
  7. return false;}
  8.  
  9. var email = form.email.value;
  10. if (email==""){
  11. alert ("Please enter E-mail Address.");
  12. form.email.focus();
  13. return false;}
  14. if (email.length >0) {
  15. i=email.indexOf("@")
  16. j=email.indexOf(".",i)
  17. k=email.indexOf(",")
  18. kk=email.indexOf(" ")
  19. jj=email.lastIndexOf(".")+1
  20. len=email.length
  21. if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
  22. }
  23. else {
  24. alert("Please enter an exact email address.\n" +
  25. email+ " is invalid.");
  26. return false;
  27. }
  28. }
  29.  
  30. if (form.daycontactno.value == ""){
  31. alert("Please enter 'Contact No'.");
  32. form.daycontactno.focus();
  33. return false;}
  34.  
  35. return true;
  36. }
  37. </script>

And the form portion:

Expand|Select|Wrap|Line Numbers
  1. <p>Fields marked with * are mandatory</p>
  2. <form action="feedback.asp" method="post" name="form" onsubmit="return Validation(this)">
  3. <table width="96%" border="0" cellspacing="0" cellpadding="3">
  4. <tr>
  5. <td width="43%">First Name(s): *</td>
  6. <td width="57%"><label>
  7. <input type="text" name="name" id="name" style="width: 190px;"/>
  8. </label></td>
  9. </tr>
  10. <tr>
  11. <td>Last Name:</td>
  12. <td><input type="text" name="lastname" id="lastname" style="width: 190px;"/></td>
  13. </tr>
  14. <tr>
  15. <td>Email address: *</td>
  16. <td><input type="text" name="email" id="email" style="width: 190px;"/></td>
  17. </tr>
  18. <tr>
  19. <td>Tel: *</td>
  20. <td><input type="text" name="daycontactno" id="daycontactno" style="width: 190px;"/></td>
  21. </tr>
  22. <tr>
  23. <td>Mobile or other contact number:</td>
  24. <td><input type="text" name="mobileother" id="mobileother" style="width: 190px;"/></td>
  25. </tr>
  26. <tr>
  27. <td>Query:</td>
  28. <td><textarea name="query" id="query" style="width: 190px;"></textarea></td>
  29. </tr>
  30. <tr>
  31. <td>&nbsp;</td>
  32. <td><label>
  33. <input type="submit" name="submit" id="submit" value="Submit" />
  34. </label></td>
  35. </tr>
  36. </table>
  37. </form>
Any improvements or suggestion welcomed.

TIA

T
Mar 12 '09 #1
6 1976
Frinavale
9,735 Expert Mod 8TB
Well, seeing that they are complaining that the submits are happening since the users do not have JavaScript enabled (and not the more obvious reason: the users are submitting the page with no information)....you could force them to enable JavaScript before viewing your page.

To do this, add <noscript> tags to your html.
The content within the <noscript> tag will be displayed if JavaScript is disabled or not supported by the browser.

For example:

Expand|Select|Wrap|Line Numbers
  1. <noscript>
  2. <div style="width:50%; margin-left: auto; margin-right:auto; background-color:#C0000; color:white; font-size: 22px;">
  3.     In order to access this web site you must have JavaScript enabled.
  4. </div>
  5. </noscript>
  6.  
  7. <!-- Your regular web content goes here -->
  8.  
Now, of course, you can place nicer HTML in in the <noscript> tag...
But I think you get the point


-Frinny
Mar 12 '09 #2
excellent. I will insert this into the html code and see what sort of response i get back from the client.

Thanks
Mar 12 '09 #3
Dormilich
8,658 Expert Mod 8TB
to really force them to use javaScript, you could go as far as omitting the submit button in the HTML code and add it via JavaScript.
like
Expand|Select|Wrap|Line Numbers
  1. function makeSubmit()
  2. {
  3.     // create the input element
  4.     var inp = document.createElement("input");
  5.     // further generation code
  6.     document.getElementById("your_form_id").appendChild(inp);
  7. }
  8.  
  9. window.addEventListener("load", makeSubmit, false);
  10. // use addEvent() function (=> google) for cross browser compatibility
Mar 12 '09 #4
Frinavale
9,735 Expert Mod 8TB
Ok that's a little bit mean!
And not to mention confusing to the end user!

A message should at least be displayed informing them that they need to enable JavaScript!
Mar 12 '09 #5
Dormilich
8,658 Expert Mod 8TB
at least it makes sure, that you don't submit unchecked forms (of course the "please use javaScript" notification is required anyway). If you call that mean.....
Mar 12 '09 #6
acoder
16,027 Expert Mod 8TB
You should validate on the server-side too, so if someone has JavaScript disabled, it will display error messages when they submit.
Mar 12 '09 #7

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

Similar topics

4
by: sean | last post by:
HI All, I have a function that validates a form, when the function returns true or false it still does not submit the form. I am using a <div> tag with text to submit the form. I have tried the...
5
by: Advo | last post by:
Basically, im redesigning a form page on our website. Currently the user submits the form, it does a few javascript checks and either submits to the "processstuff.php" page, or gives the user a...
2
by: 0utlawza | last post by:
Hi Guys Please excuse the Newbie question. I am not really a programmer so excuse me if i dont clarify my point correctly. I am trying to debug an ex-employee's web code and seem to sinking here....
13
Frinavale
by: Frinavale | last post by:
I've been trying all morning to cancel a form submit to the server. I have a JavaScript Object that determines whether or not the page should be submitted to the server depending on whether the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.