zoukankan      html  css  js  c++  java
  • indexOf 实例

     indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置。

      value:必需,规定需检索的字符串值。可选的整数参数。

      index:规定在字符串中开始检索的位置。它的合法取值是 0 到 stringObject.length - 1。如省略该参数,则将从字符串的首字符开始检索。

    indexOf 实例

    <script type="text/javascript">    
      if((yx.email.value.indexOf('@',0)==-1)||(yx.email.value.indexOf('.',0)==-1)){
        console.log("邮箱地址错误");
      }
    </script>

    注释:indexOf() 方法对大小写敏感!

    注释:如果要检索的字符串值没有出现,则该方法返回 -1。

    未完,待续......
  • 相关阅读:
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    8.React 组件封装
    window.location / history / 以及相关事件
  • 原文地址:https://www.cnblogs.com/zhishiyv/p/14630693.html
Copyright © 2011-2022 走看看