mubeenji
Posts : 1 Points : 3 Reputation : 0 Join date : 2012-01-19
| Subject: cs101 assignment no 4 complete solution Thu Jan 19, 2012 10:50 pm | |
| function ValidateStartField() { var chk = /^\d+$/.test(document.forms["mubeen"]["start"].value); if (!chk) { window.alert("Please Enter Numeric Value in start field"); document.forms["mubeen"]["start"].value=""; document.forms["mubeen"]["start"].focus(); return false; } var x=document.forms["mubeen"]["start"].value; if (x==0 || x=="" || x<2 || x>20) { window.alert("The value of Start field should be between 2 to 20"); document.forms["mubeen"]["start"].value=""; document.forms["mubeen"]["start"].focus(); return false; } else { return true; } }
function ValidateEndField() { var chk = /^\d+$/.test(document.forms["mubeen"]["end"].value); if (!chk) { window.alert("Please Enter Numeric Value in end field"); document.forms["mubeen"]["end"].value=""; document.forms["mubeen"]["end"].focus(); return false; } var x=document.forms["mubeen"]["end"].value; if (x==0 || x=="" || x<1 || x>20) { window.alert("Please Enter Value Greater then Zero"); document.forms["mubeen"]["end"].value=""; document.forms["mubeen"]["end"].focus(); return false; } } function ValidateSizeField() { var chk = /^\d+$/.test(document.forms["mubeen"]["size"].value); if (!chk) { window.alert("Please Enter Numeric Value in size field"); document.forms["mubeen"]["size"].value=""; document.forms["mubeen"]["size"].focus(); return false; } else if (document.forms["mubeen"]["size"].value<0 ) { window.alert("Please Enter Value Greater then Zero"); document.forms["mubeen"]["size"].value=""; document.forms["mubeen"]["size"].focus(); return false; } else if (document.forms["mubeen"]["size"].value>20 || document.forms["mubeen"]["size"].value <2 ) { window.alert("The value of Size field should be between 2 to 20"); document.forms["mubeen"]["size"].value=""; document.forms["mubeen"]["size"].focus(); return false; } else { true; } }
function DisplyTable() { var a=document.forms["mubeen"]["start"].value; var b=document.forms["mubeen"]["end"].value; var z1=document.forms["mubeen"]["size"].value; m=parseInt(a); u=parseInt(b); b=parseInt(z1); u=u+1; b=b+1 document.write(' '); document.write(''); var c=1; for (i=a;i{ document.write(''); document.write(' Table of '+i+''); document.write(''); for (j=1;j{ document.write('' +i+ ' | '); document.write('* | '); document.write('' +j+ ' | '); document.write('= | '); document.write('' +i*j+ ' | '); document.write(' '); } document.write(' '); document.write(' | '); c=c+1; if (c>4) { document.write(' '); c=1; } } document.write(''); document.write(' '); } function GenerateTables() { if (!ValidateStartField()||!ValidateEndField()||!ValidateSizeField() ) { } if (ValidateStartField()&&ValidateEndField()&&ValidateSizeField() ) { } else { DisplyTable(); } }
Composed: by Mubeen Mehmood Id: MC110401647 | |
|