Jump to content

Search the Community

Showing results for tags 'form validation'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH


  • Community Calendar




Website URL








Found 6 results

  1. I have a form written using HTML5 and CSS3, final validation is performed on submit with JavaScript. Then, the form will be sent to the server, most likely using PHP's mail() function. I don't recall how to include two items such as these in a form's action="...", I'd deeply appreciate if someone could refresh my memory! Thank you
  2. I'm learning php & sql. I can do the programming and logic, but how to put it all together is where I get confused. I have copied, from the w3 tutorial, the php form validation complete, and it worked fine. I have also used the php/sql database tutorial to copy the 'insert into' code and it works fine with a Db I set up on the local host. Now I would like to save the info in the form to a database table, but I'm not sure where to insert the code to connect to the database. I tried just adding the code at the bottom of the 'Form Complete' code but it didn't seem to take - no error codes but didn't get saved to the table. If I should keep it as a separate file, how and where do I call that file with the parameters I want to insert into the database? Is there anything on the w3 site that deals with this 'real life' situation. The tutorials are very good, but (everybody's got a big butt) the examples all use literals and they don't relate to a problem like I've explained here. I mean, why else would you have somebody fill in a form except to save the info in a table for future reference?? Any help going forward would be greatly appreciated. I didn't post the code here to save space, so if you're not sure what code I'm talking about, it's at w3schools and under PHP tutorial goto PHP forms 'Form Complete' and just below that in the SQL section is the code for Inserting data into a mySQL database. If I need to, I will post it. Thanx, Gil
  3. Form validation

    Hello everyone I'm trying to find out where is the problem in applying the PHP tutorial here on w3schools !!! in lesson validating an html form I apply it but it didn't work !!!! So I started from the beginning so I've created a very simple html form like this: <!DOCTYPE HTML> <html> <head> <title>th_1</title> <style> .error {color: #FF0000;} </style> </head> <body> <form method="post" action="tp_1.php"> <input type="text" name="Fname" ><span class="error"> * <?php echo $FnameErr;?></span> <p></p> <input type="submit" name="submit" value="Submit"> </form> </body> </html> and the tp_1.php is: <!DOCTYPE HTML> <html> <head> <title>tp_1</title> </head> <body> <?php // define variables and set to empty values $Fname = ""; $FnameErr = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["Fname"])) { $FnameErr = "Name is required"; } else { $Fname = test_input($_POST["Fname"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> </body> </html> So, when I leave the text box blank instead I receive "Name is required" message next to the text box I receive Internal Server error..!!! Can anyone tell me where is the error..!!!!? Thank you all
  4. Can We validate Form Fields with CSS3?

    Is there any way that we can validate our form fields with CSS3. I know that with HTML5 we can.
  5. using trim

    Do you think that when I validate form with js I should use trim() for removing the whitespace or I should leave this entirely on server-side code?
  6. Simple Form Validation

    Hello I've just done my first form validation and need help with one little niggle. The problem is with the "resetForm" Function. It works in terms of clearing the form but the alert that shows is the first alert for Function validateForm i.e."We would like to know your name! A first name must be entered". Can someone see where I have gone wrong?? So the JavaScript at the mo is this: function validateForm(){var x=document.forms["contact"]["fname"].value;if (x==null || x=="") { alert ("We would like to know your name! A first name must be entered"); return false; }var x=document.forms["contact"]["lname"].value;if (x==null || x=="") { alert ("We would like to know your name! A last name must be entered"); return false; }var x=document.forms["contact"]["email"].value;var atpos=x.indexOf("@");var dotpos=x.lastIndexOf(".");if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Please enter a valid email address"); return false; } }function show_alert(){alert("Entering a postcode informs us where the demand for our service is, in turn allowing us to best serve your location. If you prefer not to give us this information just leave the field blank.");}function resetForm(){ document.forms("resetForm").reset(); alert("The form has been cleared") } An then the HTML form is this: <form name="contact" action="mailto:mypartplanner@hotmail.co.uk" enctype="text/plain" onsubmit="return validateForm()" method="post"> <p> First Name: * <input type="text" name="fname" size="20"> </p> <p> Last Name: * <input type="text" name="lname" size="20"> </p> <p> Post Code: <input type="text" name="postcode" size="20"> </p> <p> <input type="button" onclick="show_alert()" value="Why a Postcode?"/></p> <p> Email: * <input type="text" name="email" size="20"> </p> <p> Phone Number: <input type="text" name="phonenumber" size="20"> </p> <p> Reason for Contacting: <select name="regarding"> <option> Praise <option> Criticism <option> Supplier Review <option> Supplier Recommendation <option> Listing Application <option> Other </select></p> <p> Comments: <textarea name="comments" rows="10" cols="50"></textarea></p> <br> <p> * Required Field </p> <p><input type="image" src="submitbutton.gif" height="40" width="100" border="0" alt="Submit Form"></p> <p><input name="resetForm" type="image" src="clearbutton.jpg" height="30" width="90" onClick="this.form.reset()"/></p> </form> Many Thanks!