Hi
I am working in submit form validations using mobile jquery. But is not working. I tried basic html using form with validations Its working fine. Below code.
HTML
<html>
<head>
<title>Form Validation</title>
<script type="text/javascript">
<!--
function validate()
{
if( document.myForm.Name.value == "" )
{
alert( "Please provide your name!" );
document.myForm.Name.focus() ;
return false;
}
if( document.myForm.EMail.value == "" )
{
alert( "Please provide your Email!" );
document.myForm.EMail.focus() ;
return false;
}
if( document.myForm.Zip.value == "" ||
isNaN( document.myForm.Zip.value ) ||
document.myForm.Zip.value.length != 5 )
{
alert( "Please provide a zip in the format #####." );
document.myForm.Zip.focus() ;
return false;
}
if( document.myForm.Country.value == "-1" )
{
alert( "Please provide your country!" );
return false;
}
return( true );
}
//-->
</script>
</head>
<body>
<form action="/cgi-bin/test.cgi" name="myForm" onsubmit="return(validate());">
<table cellspacing="2" cellpadding="2" border="1">
<tr>
<td align="right">Name</td>
<td><input type="text" name="Name" /></td>
</tr>
<tr>
<td align="right">EMail</td>
<td><input type="text" name="EMail" /></td>
</tr>
<tr>
<td align="right">Zip Code</td>
<td><input type="text" name="Zip" /></td>
</tr>
<tr>
<td align="right">Country</td>
<td>
<select name="Country">
<option value="-1" selected>[choose yours]</option>
<option value="1">USA</option>
<option value="2">UK</option>
<option value="3">INDIA</option>
</select>
</td>
</tr>
<tr>
<td align="right"></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
That i converted that HTML into Mobile jquery; Its not working. please anyone help me.
Below mobile jquery code
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name ="viewport" content ="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script>
function validate()
{
if( document.myForm.Country.value == "-1" )
{
alert( "Please provide your country!" );
return false;
}
return( true );
}
</script>
</SCRIPT>
</head>
<body>
<div data-role="page" id="main">
<div id="header">
<div align="center"><img src="images/logo1.jpg" width="200" height="80" /></div>
<div align="center" class="headline">
</div>
</div>
<!--<div data-role="header" data-theme="a">
<div align="center" class="head">
<a href="" rel="external" class="head1">Definir Servico</a>
<a href="" rel="external" class="head2">Reservar Horario</a>
<a href="" rel="external" class="head3">Cadastro</a>
</div>
</div>-->
<div data-role="content">
<div align="center">
<a href="" ><img src="images/but1.png" width="85" height="40" alt="Definir Servico" /></a>
<a href="" ><img src="images/but2.png" width="85" height="40" alt="Reservar Horario" /></a>
<a href="" ><img src="images/but3.png" width="85" height="40" alt="Cadastro" /></a>
</div>
<div class="holder" align="center">
<form action="new.html" name="myForm" onsubmit="return(validate());">
<div class="holder-tab">
<select name="Country">
<option value="-1" selected>[choose yours]</option>
<option value="1">USA</option>
<option value="2">UK</option>
<option value="3">INDIA</option>
</select>
</div>
<input type="submit" value="Submit" />
</form>
</div>
</div>
<br/>
</div>
</body>
</html>