Jump to content

Search the Community

Showing results for tags 'validate'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 5 results

  1. I'm making a simple contact form which works and I would like to have the user add in either their phone number OR their email. Both are fine, but at least one is required. I don't want to require both. Anyway, I created an if statement in my php code which works but when I have it return to the form, of course the form has been cleared of the user input. I then decided to create a javascript statement that does the same thing, but it clears the form as well. I personally hate it when that happens to me, so I want to make sure that whoever is filling out the form doesn't lose their information if they forget to input their phone number or email. I'm just learning to code, so I'm not sure what I should do to fix this problem. Is there some sort of HTML code I could use so that one of the two is required before the user hits the submit button? As I said before, I don't want to use the required function for either input. I appreciate any response! 😊
  2. Hi all, I have a problem for sanitizing / validating a web address input. My personal favor is doing it with regex. I made a simple example with preg_replace <?php if (!empty($_POST['wbddrss']) ) { $wbddrss = $_POST['wbddrss']; $wbddrss = trim($wbddrss); var_dump($wbddrss); $validate = preg_replace('/<>/' , '', $wbddrss); var_dump($validate); } ?> But I would like to replace all chars that do not meet what is allowed. I guess the best solution would be to replace everything with a caret to negate. But it seems I cant find the right delimiters. This is the range of characters I would like to allow: A-Za-z0-9+&@#/%?=~_|!:,.;\(\) how is this done in a preg_replace function?
  3. First of all, i am particularly focusing on the cross-reference across files feature. What is it? Simply say, it is like writing Java in Eclipse or Netbeans: When we "dot" a class, a pull down list of member variables show up. When we "ctrl + click" on a usage (of a variable, of a class, of a method, etc), it jumps to the definition of it. I particularly see this feature very helpful, especially when our project goes huge. If we don't need the benefits from this feature, why not use the free and quick editor - Notepad++ ? Many PHP dev tools are equipped with the reference feature. But not many of them can do it across different files. (means in case the definition occurs in a different file of usage.) While I was finding such a (free) IDE which can do this, I heard people keep saying the Eclipse PDT cannot reference across files. Until today, I give it a try. And surprisingly, Eclipse can do it! With the following code snippets: Car.php <?phpclass Car { public function get_type() { return $this->type; // reference OK } public $type = 'ferrari';}class Engine { public function running_in() { // in same file $car = new Car(); // of course this can ref Car echo $car->get_type(); // of course this ok too return $car->type; // of course this ok as well }}?> Driver.php <?php//include 'Car.php'; // works even without include$car = new Car(); // reference OKecho $car->get_type(); // reference OKecho $car->type; // reference OK?> Although this is a good news. Yet I still want to know why people says Eclipse PDT cannot reference across files? Is there any misunderstandings, that I am implementing it wrongly? Also, as many people say, Eclipse is slow because it is Java based. I am ok with the speed. But I still want a comparison list of features of different Web Dev IDE. Thanks for any input about Web Dev Tool discussion! P.S. In addition, JavaScipt list of methods with browser supporting versions (like what Aptana has) would be a very nice feature too!
  4. I was looking through some ways to validate email. I saw the one on w3schools, but that is a basic one, so I started to code something more complicated adding all those if, else if, else statements, etc. Then I came across this... function validateEmail(email){var allowed=/^([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$)/; return allowed.test(email);} Is something that simple sufficient enough? Everything seems to look as if it would work. Also, what does the "$" do?
  5. I created a php contact form for our Technology department in a school district. I would like to make a particular field required or optional based on the choice made in a dropdown menu.So, if the user chooses the Hardware or Software category, I want the barcode field to be required. If they choose Username/Password, I want the barcode field to be optional.Here is the part of the code that is validating fields: function died($error) { // your error code can go here echo "<b>We are very sorry, but there were error(s) found with the form you submitted.</b><br /> <br />"; echo $error."<br />"; echo "Please go back and fix these errors.<br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['location']) || !isset($_POST['email']) || !isset($_POST['machine']) || !isset($_POST['problem'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $location = $_POST['location']; // required $email_from = $_POST['email']; // required $machine = $_POST['machine']; // required $barcode = $_POST['barcode']; // not required $problem = $_POST['problem']; // required $issue = $_POST['issue']; $error_message = ""; if(($issue) == '') { $error_message .= 'Please select a category.<br />';} if(($issue) == "Hardware" || "Software" && ($barcode) == '') { $error_message .= 'The Service Tag/Barcode you entered does not appear to be valid.<br />'; } $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z0-9, .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$location)) { $error_message .= 'The Location you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$machine)) { $error_message .= 'The Machine you entered does not appear to be valid.<br />'; } if(strlen($problem) < 2) { $error_message .= 'The problem you entered does not appear to be valid.<br />'; } if(strlen($error_message) >= 1) { died($error_message); } The problem is that this always setting $error_message to 'The Service Tag/Barcode you entered does not appear to be valid.<br />'. So, when user selects Username/Password the error message is still preventing the script from sending the email.Any ideas?Lucas Land
×
×
  • Create New...