My goal is to have a textbox that receives an IP address and validates it before submission. To achieve this, I've developed a JavaScript class called `validityCheck`.
In my main Vue.js component, I aim to utilize this class to validate the input's format as a correct IP address.
Although currently the validation process does not execute any actions. How can I implement this validation here?
Below is the code for the validity check class:
const validations = '^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$';
function validationInput(input) {
if (validations.test(input)) {
return false;
}
return true;
}
export default validationInput;
Here is the main component structure:
<TextBox :label="$t('ChangeServerIpAddress')" v-model="ipAddress" @input="validationInput" />
<p v-if="false">IP address is not valid</p>