RegularExpressionValidator

S

simonZ

I have RegularExpressionValidator which validate one text box.
When my text box is validated on client I would like to do something else.

Is there some client event of RegularExpressionValidator?

Something like after validate?

something like:

<script language="javaScript">
function afterValidate(arg){
if (arg.isValid )
{
//do something
}
}
</script>

regards,S
 
S

simonZ

Thank you, Milosz

this was exactly what I needed.

Regards,S

Milosz Skalecki said:
Hi Simon,

Client side validation API:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp

There are many ways to accomplish this task:

- you can force validators to run their validation methods by calling
ValidatorValidate(val)
- instead of using reqularexpressionvalidator, use customvalidator in
conjunction with clinetfunctionname property, and Regex DOM object (it's
easy to incorporate the same functionality as regularexpressionvalidator)

example :


<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
ErrorMessage="try again...."
OnServerValidate="CustomValidator1_ServerValidate"/>

<script runat="server">

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
"[0-9]+");
}

</script>

<script language="javascript">
function MyValidationFunction(src, e)
{
e.IsValid = e.Value.match('[0-9]+');

// do something here...
}
</script>
--
Milosz Skalecki
MCAD


simonZ said:
I have RegularExpressionValidator which validate one text box.
When my text box is validated on client I would like to do something
else.

Is there some client event of RegularExpressionValidator?

Something like after validate?

something like:

<script language="javaScript">
function afterValidate(arg){
if (arg.isValid )
{
//do something
}
}
</script>

regards,S
 
B

bruce barker

note, this article is for version 1. client side validation is simular
for version 2, but there are implementation differences (javascript
variables instead of spans, for example).

-- bruce (sqlwork.com)
 
S

simonZ

Well, it doesn't help much, because client side validation doesn't work in
firefox.
So, I must create on some other way.

regards,Simon


simonZ said:
Thank you, Milosz

this was exactly what I needed.

Regards,S

Milosz Skalecki said:
Hi Simon,

Client side validation API:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp

There are many ways to accomplish this task:

- you can force validators to run their validation methods by calling
ValidatorValidate(val)
- instead of using reqularexpressionvalidator, use customvalidator in
conjunction with clinetfunctionname property, and Regex DOM object (it's
easy to incorporate the same functionality as regularexpressionvalidator)

example :


<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
ErrorMessage="try again...."
OnServerValidate="CustomValidator1_ServerValidate"/>

<script runat="server">

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
"[0-9]+");
}

</script>

<script language="javascript">
function MyValidationFunction(src, e)
{
e.IsValid = e.Value.match('[0-9]+');

// do something here...
}
</script>
--
Milosz Skalecki
MCAD


simonZ said:
I have RegularExpressionValidator which validate one text box.
When my text box is validated on client I would like to do something
else.

Is there some client event of RegularExpressionValidator?

Something like after validate?

something like:

<script language="javaScript">
function afterValidate(arg){
if (arg.isValid )
{
//do something
}
}
</script>

regards,S
 
G

Guest

Hi Simon,

Yes, it does, show me the code you're having problems with

Regards
--
Milosz Skalecki
MCAD


simonZ said:
Well, it doesn't help much, because client side validation doesn't work in
firefox.
So, I must create on some other way.

regards,Simon


simonZ said:
Thank you, Milosz

this was exactly what I needed.

Regards,S

Milosz Skalecki said:
Hi Simon,

Client side validation API:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp

There are many ways to accomplish this task:

- you can force validators to run their validation methods by calling
ValidatorValidate(val)
- instead of using reqularexpressionvalidator, use customvalidator in
conjunction with clinetfunctionname property, and Regex DOM object (it's
easy to incorporate the same functionality as regularexpressionvalidator)

example :


<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
ErrorMessage="try again...."
OnServerValidate="CustomValidator1_ServerValidate"/>

<script runat="server">

protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
"[0-9]+");
}

</script>

<script language="javascript">
function MyValidationFunction(src, e)
{
e.IsValid = e.Value.match('[0-9]+');

// do something here...
}
</script>
--
Milosz Skalecki
MCAD


:

I have RegularExpressionValidator which validate one text box.
When my text box is validated on client I would like to do something
else.

Is there some client event of RegularExpressionValidator?

Something like after validate?

something like:

<script language="javaScript">
function afterValidate(arg){
if (arg.isValid )
{
//do something
}
}
</script>

regards,S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top