actually im new here and in js. i want one more function there like the numeric value should be equal to 11digit as mobile number.
i think that code should be like
HTML Code:
<script language="JavaScript">
	function onlyNumbers()
	{
		valid=true;
		var Numbers = '0123456789';
		var Field1 = document.Form1.consumerno.value;
		var Field2 = document.Form1.mobile.value;

		if (Field1 == "")
		{
			alert ( "Please fill in your consumer no.." );
			valid = false;
		}
		if (Field2 == "")
		{
			alert ( "Please fill in your mobile no.." );
			valid = false;
		}
		for (i=0; i < Field1.length; i++)
		{
			if (Numbers.indexOf(Field1.charAt(i),0) == -1)
			{
				alert ( "Numbers only in Consumer Number." );
				valid = false;
				break;
			}
		}
		for (i=0; i < Field2.length; i++)
		{
			if (Numbers.indexOf(Field2.charAt(i),0) == -1)
			{
				alert ( "Numbers only in Mobile Number." );
				valid = false;
				break;
			}
		}
		return valid;
	}
	function validateForm(Form1)
 	{
	  Form1.onsubmit = function(){
		if(Form1.elements['mobile'].value.length<>11)
 		{
 			alert("You must put 11 digit!");
 			return false;
 		}


		}
</script>
or what would be better

Last edited by shabbir; 7Dec2009 at 09:19.. Reason: Code blocks