473,782 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

blank form submits

3 New Member
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 1990
Frinavale
9,735 Recognized Expert Moderator Expert
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
0utlawza
3 New Member
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 Recognized Expert Moderator Expert
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 Recognized Expert Moderator Expert
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 Recognized Expert Moderator Expert
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 Recognized Expert Moderator MVP
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
5791
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 following ways to make the form submit & validate at the same time; 1. I have tried the onsubmit function at the top of the form, this seems to only work with a form button or an image.
5
1940
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 JS error message.. where they have to go back and fill the details in. Im trying to optimise and make this form/page as best as it can be. Do you think it would be a better idea to continue using JS or use JS then submit to the php page(where...
2
1742
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. 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...
13
10569
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 user clicks "yes" or "no". This Object is attached to various HTML elements on the page (buttons, selects etc) and traps any events that they raise that cause the page to submit. If the user has not responded, the Object should cancel the page...
0
10311
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.