Javascript validate the master and content page
-
hai all
i want to validate the content page using javascript external file.
i keep 5 text box in content page.i want to validate the textbox like
fields must not blank,
characters only allowed for name,state,country.
numbers only allowed for age,pincode
email validation etc.
i want to validate the textboxes in content page using javascript external file.
how to do these...plz send javascript code...thanks in advance... -
hai all
i want to validate the content page using javascript external file.
i keep 5 text box in content page.i want to validate the textbox like
fields must not blank,
characters only allowed for name,state,country.
numbers only allowed for age,pincode
email validation etc.
i want to validate the textboxes in content page using javascript external file.
how to do these...plz send javascript code...thanks in advance...Firstly, Why did you put your question in a code block, doesn't look very clever............ Ok, so back to your question; You can use the object onChange to call a javascript function to validate the content as each element changes. You could also use a button when you submit to check each element. The code below is a sample to help you get going, but there are heaps of examples on the net. You could take all the javascript out of the lower script block and place it in a reference file as shown in the upper script block entry
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title><script type="text/javascript" src="js/thejsfile.js"></script>
</head>
<body><table> <tr><td>Name:</td><td><input id="textName" type="text" onchange="validateName()"/></td><td id="nameValidMessage"></td></tr> <tr><td>Age:</td><td><input id="textAge" type="text" onchange="validateAge()"/></td><td id="ageValidMessage"></td></tr> </table> <input id="ButtonGo" type="button" value="Go" onclick="go\_click()"/> <script type="text/javascript"> function validateAge() { var valid = false //write you code to validate the age //set valid to true if all ok if (textAge.value == "99") { valid = true; } //update the page message if (!valid) { ageValidMessage.innerHTML = "Invalid Age"; } else { ageValidMessage.innerHTML = ""; } return valid } function validateName() { var valid = false //write you code to validate the name //set valid to true if all ok if (textName.value == "Dave") { valid = true; } //update the page message if (!valid) { nameValidMessage.innerHTML = "Invalid Name"; } else { nameValidMessage.innerHTML = ""; } return valid } function go\_click() { var valid
-
hai all
i want to validate the content page using javascript external file.
i keep 5 text box in content page.i want to validate the textbox like
fields must not blank,
characters only allowed for name,state,country.
numbers only allowed for age,pincode
email validation etc.
i want to validate the textboxes in content page using javascript external file.
how to do these...plz send javascript code...thanks in advance...hi i just wanted to know whether u got a solution for your question because i am facing the same problem now but still did not get any solution for it....i need to use javascript to validate a textbox placed in content page so can u plz help me in this issue....i am not able to get the id of the textbox.... K.Gayathri