Home > Java Script, Logic, Tricks > Javascript Validation

Javascript Validation

Hai Friends.

One time i tried to do  simple form validation..But ,it is not work properly even i code correctly..After spending long tome i got the solution which i want to share with you to save your time..one mistake i did which is just when i call the function it does not work properly…Instead when i am using retun validate(nam,pass) it works correctly…

<script type=”text/javascript”>

function validate(a,b)

{
if(a.value.length==0 || b.value.length==0)

{

alert(“Please fill your Username & Password”);

return false;

}

else

return true;

}

</script>

<form action=”send.php” method=”post”>

Username : <input type=”text” name=”nam”>

Password : <input type=”password” name=”pass”>

<input type=”submit” value=”Submit” onClick=”return validate(nam,pass)“>

</form>

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: