Validate form fields Selenium
<p>I'm trying to make sure that in a "text box" I can only input specific characters , and or only numbers.
I want to to this with selenium , but I seem unable to reach the script throw selenium.
Im able to check the properties of the text box but not the script itself , since this one does not appear on screen.</p>

<p>Here is the code I want to check.
<strong>How can I test the script through selenium?</strong></p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Simple form&lt;/title&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;        

        &lt;meta name="mobile-web-app-capable" content="yes"&gt;
        &lt;meta charset="utf-8"&gt;
    &lt;/head&gt;

    &lt;body&gt;
        &lt;div&gt;
            &lt;form onsubmit="return Validted()"&gt;
                New user registration:&lt;br&gt;&lt;br&gt;
                &lt;table&gt;
                    &lt;tr&gt;
                        &lt;td&gt;
                            First name: *
                        &lt;/td&gt;
                        &lt;td&gt;
                            &lt;input type="text"  id="f_name"     name="fname"  maxlength="128" value="" class="firstn"  placeholder="first name" style="border-color: gray"&gt;&lt;br&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;
                            Last name:  *
                        &lt;/td&gt;
                        &lt;td&gt;
                            &lt;input type="text"  id="l_name"     name="lname"  maxlength="128" value="" class="lastn"   placeholder="last name"  style="border-color: gray"&gt;&lt;br&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;
                            Password:   *
                        &lt;/td&gt;
                        &lt;td&gt;
                            &lt;input type="password"  id="pass"   name="pass"   maxlength="128" value="" class="pass"    placeholder="password"  style="border-color: gray"&gt;&lt;br&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;
                            Phone:      *
                        &lt;/td&gt;
                        &lt;td&gt;
                            &lt;input type="tel"   id="tel"        name="tel"    maxlength="15"  value="" class="phone"   placeholder="phone number"  style="border-color: gray"&gt;&lt;br&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;
                            E-mail:     *
                        &lt;/td&gt;
                        &lt;td&gt;
                            &lt;input type="email" id="user_email" name="email"  maxlength="128" value="" class="eml"     placeholder="Enter email"  style="border-color: gray"&gt;&lt;br&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
                &lt;input type="submit" value="Register"&gt;
            &lt;/form&gt;
        &lt;/div&gt;

        &lt;br&gt;password rules: &lt;br&gt;
        only 0-9a-zA-Z         &lt;br&gt;
        at least 8 characters &lt;br&gt;
        at least 1 number &lt;br&gt;
        at least 1 lowercase character (a-z) &lt;br&gt;
        at least 1 uppercase character (A-Z) &lt;br&gt;


        &lt;script&gt;
            var validEmail = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            var validPhone = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/;
            var validPass = /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])([a-zA-Z0-9]{8})$/;
            function testThis(what, reg, fld) {
                if (reg.test(what)) {
                    $('.' + fld).css('color', 'green');
                    console.log(fld);
                    return true;
                }
                else {
                    $('.' + fld).css('color', 'red');
                    return false;
                }
            }

            function Validted() {
                $('.pass').css('border-color', 'gray');
                $('.phone').css('border-color', 'gray');
                $('.eml').css('border-color', 'gray');

                if (!testThis($('#user_email').val(), validEmail, 'eml')) {
                    $('.eml').css('border-color', 'red');
                    return false;
                }
                if (!testThis($('#pass').val(), validPass, 'pass')) {
                    $('.pass').css('border-color', 'red');
                    return false;
                }
                if (!testThis($('#tel').val(), validPhone, 'phon')) {
                    $('.phone').css('border-color', 'red');
                    return false;
                }

                return true;
            }

            function validatePass() {
                $('#pass').keyup(function () {
                    return testThis(this.value, validPass, 'pass');
                });
            }
         }
</code></pre>