Home  >  Article  >  Development Tools  >  Custom verification code for SPRY in DreamWeaver CS3

Custom verification code for SPRY in DreamWeaver CS3

不言
不言forward
2018-09-29 16:01:054963browse

The content of this article is about the custom verification code of SPRY in DreamWeaver CS3. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

In the past two days, I have used the SPRY component in DreamWeaver CS3. Found that it can automatically perform front-end authentication on some inputs. It is quite convenient. It has some built-in verification content, such as: number verification, string verification, postal code verification, date verification, etc.

However, the fly in the ointment is that some of its built-in verifications are not very practical in China, because some of the verifications it provides are based on American standards, which are somewhat different from Chinese standards. gap.

At this time, the only thing that comes to mind is to extend its verification. I don’t want to modify its code because I’m not good enough. See if there are other ways. After looking for some information on the Internet and through my own practice, I finally succeeded. Now assign the code after it.

<span id="sprytextfield1">
<input type="text" name="text1" id="text1"  />
<span class="textfieldRequiredMsg">需要提供一个值。</span>
 <span class="textfieldInvalidFormatMsg">数据无效。</span></span>

This is a piece of code generated by manually dragging a SPRY text box for verification.

The following is a code that declares SPRY

<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField
("sprytextfield1", "custom", {validateOn:["blur"],validation:EXT});
//-->
</script>

The last validation: EXT was added manually by me, indicating that the verification of SPRY is achieved by calling the EXT function. EXT returns True, indicating that the verification passes, EXT returns False, indicating that the verification fails. (EXT is the function name, you can define it by yourself, but this method does not seem to be able to pass parameters)

<script language="javascript">
var EXT = function(){
var objReg=/(13)(\d{9})/;
        t=form1.text1.value;
return objReg.test(t);
    }
</script>

The above code means that when verifying the content of text1, it matches the Chinese mobile phone number.

We can achieve custom verification effects by modifying the EXT function. For example: verify whether the contents in the password box and the repeat password box are the same.

<script language="javascript">
var EXT = function(){
return (form1.Pass.value==form1.RePass.value);
    }
</script>

The above is the detailed content of Custom verification code for SPRY in DreamWeaver CS3. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete