只能输入数字


 keypress(e)
{
if ([e.keyCode||e.which]==8//this is to allow backspace
    return true;
if ([e.keyCode||e.which] < 48 || [e.keyCode||e.which] > 57)
    e.preventDefault
? e.preventDefault() : e.returnValue = false;
}
</script>
<input type="text" name="textbox1" id="textbox1" onKeypress='keypress(event)'>

EMail判断


    function isEmailFormatValid(emailSrc) {
     
var email = emailSrc.replace(/^\s+|\s+$/g, '');
     
if (email == '') {
      
return false;
     }
     
     
var regex = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
      
if (regex.test(email)) {
       
var str = " !#$%^&*()+=|\{[]}:;'<,>?/" ;
       
var str2 = '"';
        
var result = true;
        
for (var j = 0; j < email.length; j++) {
         
if (str.indexOf(email.charAt(j)) != -1 || str2.indexOf(email.charAt(j)) != -1) {
          result 
= false;
          
break
         }
        }
        
if (result == true) {
         
return true;
        }
        
else {
         
return false;
        }
      } 
else {
        
return false;
      }
    } 

    
function btn2_Click() {
        
var strTest;
        
if (isEmailFormatValid(document.all['TextBox7'].value) == true)
        {
            strTest 
= 'It is ok'
        } 
else {
            strTest 
= 'It is failed'
        }
        alert(strTest);
    }
</script>

相关文章:

  • 2022-02-07
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2021-04-03
  • 2022-01-11
猜你喜欢
  • 2021-11-07
  • 2022-03-07
  • 2021-07-01
  • 2021-12-15
  • 2021-12-22
  • 2022-01-15
相关资源
相似解决方案