Process To Validate HTML Form With Javascript
Process To Validate HTML Form With Javascript
Process To Validate HTML Form With Javascript
com/
Process to Validate
HTML Form with
Javascript
1
http://www.guru99.com/
Scenario
As shown in screenshot, following validations are set on various fields in the Fund Trasnfer Module
When the user finishes entering value in this field and moves to next field , onBlur event will be
triggerred & Following function is called,
function validatedesc()
{
var des = document.forms[0]["desc"].value; // get the value of filed
2
http://www.guru99.com/
<html>
<head>
<li><a href="PasswordInput.php">Changepassword</a></li>
3
http://www.guru99.com/
</div>
</div>
<title>Fund Transfer Entry Page </title>
</head>
</head>
<body>
<br/><br/><br/><br/>
<tr>
<td align="center" colspan="2"><p class="heading3">Fund
Transfer</p></td>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td>Payers account no</td><td><input type="text"
name="payersaccount" value="" onBlur="validatepayersaccountno()" onKeyUp
="validatepayersaccountno()"/> <label id="message10"></label>
</tr>
<tr>
<td>Payees account no</td>
<td>
<input type="text" name="payeeaccount" value=""
onBlur="validatepayeeaccountno()" onKeyUp="validatepayeeaccountno()" />
<label id="message11"></label>
</td>
</tr>
<tr>
<td>Amount</td><td><input type="text" name="ammount"
maxlength = "8" onBlur="validateammount()" onKeyUp="validateammount()"/>
<label id="message1"></label></td>
</tr>
<tr>
<td>Description</span></td><td><input type="text" name="desc"
value="" onBlur="validatedesc()" onKeyUp="validatedesc()"/> <label
id="message17"></label> </td>
4
http://www.guru99.com/
</tr>
<tr><input type="hidden" name="formid" value="”/>
<td></td>
<td><input type="submit" name="AccSubmit" value="Submit"
onClick=" return validateone();">
<input type="reset" name="res" value="Reset"></td>
</tr>
</form>
</table>
<p align="right"><a href="Customerhomepage.php">Home</a></p>
</body>
</html>
Now , the validation functions are called on onclick(), onkeyup(), onblur(), onsubmit() events from
the test.js file called in the HEAD section.