S
Suresh.Eddala
Hi,
I am trying to do Form validation on client side by using atlas
client-centric script.
Grouping all the field validation by using "validationGroup" and on
button click event checking the validationgroup validated or not. On
focus of each field the validation is checking. I am trying to check
for the entire form at button click event and submit the form to server
side.
I have checked couple of post, not much help on it.. can any one please
let me, is there any way to achieve this..
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head id="Head1" runat="server">
<title>Client Side form validation!</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<atlas:ScriptManager runat="server" ID="ScriptManager1" />
<div class="description">
<b>Name:</b>
<input type="text" id="value1TextBox" name="username"/>
<span id="validator1" style="color: red">*</span><br />
<b>Age:</b>
<input type="text" id="value2TextBox" class="input" />
<span id="validator2" style="color:red">*</span>
<input type="button" id="btnSave" name="save"
value="Save" />
</div>
<script type="text/javascript">
function formValidate()
{
if (Page_ClientValidate("formGroup"))
alert("Form validated!");
else
alert("Form not validated!");
}
</script>
<script type="text/xml-script">
<page
xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<textBox id="value1TextBox">
<validators>
<requiredFieldValidator
errorMessage="You must enter some text." />
</validators>
</textBox>
<validationErrorLabel id="validator1"
associatedControl="value1TextBox" visibilityMode="Hide" />
<textBox id="value2TextBox">
<validators>
<requiredFieldValidator
errorMessage="You must enter a number." />
<typeValidator type="Number"
errorMessage="You must enter a valid number." />
<rangeValidator lowerBound="10"
upperBound="20" errorMessage="You must enter a number between 10 and
20." />
</validators>
</textBox>
<validationErrorLabel id="validator2"
visibilityMode="Hide" associatedControl="value2TextBox" />
<validationGroup id="formGroup">
<associatedControls>
<reference component="value1TextBox" />
<reference component="value2TextBox" />
</associatedControls>
</validationGroup>
<button id="btnSave"
click="formValidate"></button>
</components>
</page>
</script>
</div>
</form>
</body>
</html>
Thanks
Suresh
I am trying to do Form validation on client side by using atlas
client-centric script.
Grouping all the field validation by using "validationGroup" and on
button click event checking the validationgroup validated or not. On
focus of each field the validation is checking. I am trying to check
for the entire form at button click event and submit the form to server
side.
I have checked couple of post, not much help on it.. can any one please
let me, is there any way to achieve this..
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head id="Head1" runat="server">
<title>Client Side form validation!</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<atlas:ScriptManager runat="server" ID="ScriptManager1" />
<div class="description">
<b>Name:</b>
<input type="text" id="value1TextBox" name="username"/>
<span id="validator1" style="color: red">*</span><br />
<b>Age:</b>
<input type="text" id="value2TextBox" class="input" />
<span id="validator2" style="color:red">*</span>
<input type="button" id="btnSave" name="save"
value="Save" />
</div>
<script type="text/javascript">
function formValidate()
{
if (Page_ClientValidate("formGroup"))
alert("Form validated!");
else
alert("Form not validated!");
}
</script>
<script type="text/xml-script">
<page
xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<textBox id="value1TextBox">
<validators>
<requiredFieldValidator
errorMessage="You must enter some text." />
</validators>
</textBox>
<validationErrorLabel id="validator1"
associatedControl="value1TextBox" visibilityMode="Hide" />
<textBox id="value2TextBox">
<validators>
<requiredFieldValidator
errorMessage="You must enter a number." />
<typeValidator type="Number"
errorMessage="You must enter a valid number." />
<rangeValidator lowerBound="10"
upperBound="20" errorMessage="You must enter a number between 10 and
20." />
</validators>
</textBox>
<validationErrorLabel id="validator2"
visibilityMode="Hide" associatedControl="value2TextBox" />
<validationGroup id="formGroup">
<associatedControls>
<reference component="value1TextBox" />
<reference component="value2TextBox" />
</associatedControls>
</validationGroup>
<button id="btnSave"
click="formValidate"></button>
</components>
</page>
</script>
</div>
</form>
</body>
</html>
Thanks
Suresh