Form validation with javascript vs php

Asked
Active3 hr before
Viewed126 times

2 Answers

validationjavascript
90%

the javascript works perfectly,How to insert data directly yo sql database without validation code.,(need both js and php validation but not validation code, Varun Sharma Mar 9, 2013 at 1:44 pm the javascript works perfectly Reply

templates/main_page.html

<form action="index.php" method="post" id="form" onsubmit="return validate_all('results');">
   <table cellspacing="10">
      <tr>
         <td>Login</td>
         <td><input type="text" name="login" maxlength="25" id="login" onKeyUp="updatelength('login', 'login_length')"><br />
            <div id="login_length"></div>
         </td>
      </tr>
      <tr>
         <td>Password</td>
         <td><input type="password" name="pass" maxlength="25" id="password" onKeyUp="updatelength('password', 'pass_length')">
            <div id="pass_result"></div><br />
            <div id="pass_length"></div>
         </td>
      </tr>
      <tr>
         <td>Confirm Password</td>
         <td><input type="password" name="cpass" maxlength="25" id="c_password"></td>
      </tr>
      <tr>
         <td>Gender</td>
         <td><select name="gender">
               <option value="1">male</option>
               <option value="0">female</option>
            </select></td>
      </tr>
      <tr>
         <td>Email</td>
         <td><input type="text" name="email" maxlength="50" id="email" onKeyUp="updatelength('email', 'email_length')"><br />
            <div id="email_length"></div>
         </td>
      </tr>
      <tr>
         <td colspan="2"><input type="submit" name="submit" value="Register"></td>
      </tr>
   </table>
   <h3 id="results"></h3>
</form>
load more v
88%

A common example is with web forms, where it’s useful to validate user input before it’s saved to a database.,At this point, you might be wondering, “What is the difference between PHP vs JavaScript?” Actually, there are several.,As we saw earlier, JavaScript and PHP have different ways of declaring variables.,Another commonality is that PHP and JavaScript are weakly typed.

So, you can write the following in PHP:

$x = 'Hello world';

$y = 'Bonjour le monde';
load more v

Other "validation-javascript" queries related to "Form validation with javascript vs php"