Yaseen Ahmed Yaseen Ahmed - 7 months ago 29
CSS Question

How to validate a form for all browsers including mobile browsers

I have a website http://www.yaseennikah.com/MyRegister.php. I need to validate the form in client side. I used javascript code, but it is not working in some mobiles browsers. I saw a jquery code here http://jsfiddle.net/WF2J9/16/. But I don't know to add jquery ul. So can any one complete the code please.

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>form validation</title>

<form action="page1.php" method="post" class="a">
Name : <input type="text" class="text" name="name" id="name" /> <br/>
Address : <input type="text" class="text" name="address" id="address /><br/>
email : <input type="text" class="text" name="email" id="email" /> <br/>
<button id="submit" name="submit">submit</button>

$('#submit').on('click', function() {
valid = true;

if (valid && $('#name').val() == '') {
alert ("please enter your name");
valid = false;

if (valid && $('#address').val() == '') {
alert ("please enter your address");
valid = false;

return valid;


You can add jQuery to your web page using their official CDNs
Add this to the head of your web page <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

And you can test if jQuery was loaded correctly using this code

if($) {
  alert("jQuery loaded");
} else {
  alert("jQuery not loaded");

Edit: Here is my version of the validation script (now should be working)