GithubHelp home page GithubHelp logo

Comments (13)

DrRoach avatar DrRoach commented on July 24, 2024

Hello,
I think the problem is the ; after the closing / in your regex.
Try changing "/^\s$/;" to "/^\s$/". If that doesn't work, I'll have a closer look though when I get to a computer

from formvalidation.

seanvree avatar seanvree commented on July 24, 2024

Yeah, I tried removing that and a couple other combos, no dice. No worries my man. LMK

from formvalidation.

DrRoach avatar DrRoach commented on July 24, 2024

Hi, sorry about the long delay i getting back to you about this!!

Please see this commit: 7cf94b0

Firstly, I have added a regex_reverse option which will throw an invalid input if the regular expression is matched, rather than if it is not matched.

Secondly, there's some strange goings on with regards to the \ in the regular expression. The fix for this is to use double slash.

So to check to make sure that there are no whitespaces in your input you will need:

fv-advanced='{"regex": "\\s", "regex_reverse": true, "message": "This field cannot contain spaces."}' 

Hope this helps and if you have any more problems feel free to ask :)

from formvalidation.

seanvree avatar seanvree commented on July 24, 2024

@DrRoach

Hey, no problem man.

However, i think it's backwards tho. It's validating only when white spaces are PRESENT. Instead of the other way around.

I tried changing to "regex_reverse": false, but that didn't work.

image

image

from formvalidation.

DrRoach avatar DrRoach commented on July 24, 2024

Have you tried with setting regex_reverse to true?

The way that I see the regex's working is that if the pattern is there then our input is valid. Hence why when reversing that, if the pattern exists our input is invalid.

I'm not sure if this is the best implementation of reverse or whether it should be the other way around but for now I guess this is how it'll be

from formvalidation.

seanvree avatar seanvree commented on July 24, 2024

Yes. I tried setting it to true and removing the regex_reverse string all together. Still backwards.

from formvalidation.

DrRoach avatar DrRoach commented on July 24, 2024

Hmm that is strange indeed. I've created two inputs, the first with reverse = true and the second with reverse = false.

image

image

Could I ask you to do the same and also post your input code? Maybe I'm missing something

from formvalidation.

seanvree avatar seanvree commented on July 24, 2024

@DrRoach yeah, no problem:


<form id="userForm">

    <i class='fa fa-fw fa-folder-open'> </i> 
    <input type='text' name='datadir' title="Cannot contain spaces & must contain trailing slash" fv-advanced='{"regex": "\\s", "regex_reverse": true, "message": "This field cannot contain spaces."}' fv-not-empty=" This field can't be empty" id="datadir" autocomplete="off" placeholder=' Data dir path' required>

    <div>
        <input type='submit' id="datadirbtn" class="btn btn-primary" value='Create' />
    </div>

</form>

from formvalidation.

DrRoach avatar DrRoach commented on July 24, 2024

That's strange, it seems to be working okay for me, have you got the latest commits?

On a side note, I've noticed a bug where only the first validation check is ran and will aim to fix this asap. #4

from formvalidation.

seanvree avatar seanvree commented on July 24, 2024

dude @DrRoach I'm sorry brother, looks like it was a caching issue. I cleared all cache and pretty much had to shut down my box to get it to work.

Thanks brother.

FYI, implementing it on this project:

https://github.com/Monitorr/Monitorr

We'll throw you some credit.

from formvalidation.

DrRoach avatar DrRoach commented on July 24, 2024

Haha no worries at all, I've been there myself, glad that it's working now though.

Ahh looks like a cool project, I'll have to check it out in the future, thank you for that!!

from formvalidation.

seanvree avatar seanvree commented on July 24, 2024

NP, looking forward to when you can get that other bug worked out!

#4

from formvalidation.

seanvree avatar seanvree commented on July 24, 2024

@DrRoach I HATE to come back at ya with another question, but does your script run all regex patterns or do you have to code them in depending on the value?

I'm trying to get another validation to work on the same field but with another regex pattern which DOES work with the jquery.

var re = /.*[\\//]+$/;

I think the leading and trailing slashes can be removed however.

This pattern essentially ensures the last character is a backstalsh or a forwardslash.

Not sure if this was something easy...if not, no biggie.

-SV

from formvalidation.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.