Source Code

Form Validation Function

  • anonymous
  • Oct 30' 13
  • Javascript
  • 307
  • 105
  • United States

Not Empty Field

This function check if a field has been left empty. If the field is blank, an alert box alerts a message, the function returns false, and the form will not be submitted to action page:

function validfield()
var x=document.forms["myForm"]["fieldcheck"].value;
if (x==null || x=="")
  alert("Field must be filled out");
  return false;

and you call the function when event submitted

<form action="target_page.php" method="post" name="myForm" 
onsubmit="return validfield()">
Field to check : <input type="text" name="fieldcheck" />
<input type="submit" value="Submit" />

and will be shown


field check image


Happy try

  • Tags :
comments powered by Disqus

Related Code

Spell Text and Hear It

Create Symphony With Midi Sound

Get IP Address

Splash Screen

Border Radius

Session for Keep Values

Solve (LSN) Error 9003 When Attach the Database SQL2000

Zakat Counter

Looking for Date and Time Difference

Send Email Through Console