Check if a string has white space

前端 未结 7 1533
青春惊慌失措
青春惊慌失措 2020-11-30 19:41

I\'m trying to check if a string has white space. I found this function but it doesn\'t seem to be working:

function hasWhiteSpace(s) 
{
            


        
相关标签:
7条回答
  • 2020-11-30 20:07

    Here is my suggested validation:

    var isValid = false;
    
    // Check whether this entered value is numeric.
    function checkNumeric() {
        var numericVal = document.getElementById("txt_numeric").value;
    
        if(isNaN(numericVal) || numericVal == "" || numericVal == null || numericVal.indexOf(' ') >= 0) {
            alert("Please, enter a numeric value!");
            isValid = false;
        } else {
            isValid = true;
        }
    }
    
    0 讨论(0)
提交回复
热议问题