What kind of method should be used to remind users? You certainly don't want to use the alert () Prompt box
Add a Sqan tag after entering the field
<input id="Phone"Name="Phone" Type="Text"Size=" A"Onblur="Validatenonemptyfun (This,document.getelementbyid (' phone_help ')");/><span id="Phone_help" class="Help"></span>functionValidate_length (Inputfiled,helptext) {//If the input field content is empty, alert within the span tag if(inputfiled.value.length==0) {if(helptext!=NULL) helptext.innerhtml="text box cannot be empty"; }//Empty the contents of the span tag if the input field is not empty Else if(helptext!=NULL) helptext.innerhtml=""}</script>
HelpText is an incoming span object
Use span tags to remind users that they don't block user vision like alert
In addition to non-null validation, there are dimension issues
Verify data length
id="phone"name="phone" type="text" size="12" onBlur="validate_Length(1,32,this,document.getElementById(‘phone_help‘));"id="phone_help"class="help"></span>
Here the parameters become four, the first is the minimum length of text, the second is the longest length of text
function Validate_length (minlegth,maxlength,inputfiled, HelpText) {if(inputfiled.value.length<minlegth| | Inputfiled.value.length>maxlength) {if( HelpText!=null) { HelpText.innerhtml="Please enter a length of"+minlenght+"to"+maxlength+"Text";return false; } }Else if( HelpText!=null) { HelpText.innerhtml="" return true; } }
Verify postal code
function Validate_zipcode (inputfiled, HelpText) {if(inputfiled.value.length!=5) {if( HelpText!=null) HelpText.innerhtml="ZIP code must be 5-bit long";return false; }Else if(IsNaN (Inputfiled.value)) {if( HelpText!=null) HelpText.innerhtml="ZIP code must be a number";return false; }Else if( HelpText!=null) { HelpText.innerhtml="" return true; } }
7.1 Javascript: Forms and validation-length validation